Blame SOURCES/gdb-6.5-section-num-fixup-test.patch

b2f73e
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
b2f73e
From: Fedora GDB patches <invalid@email.com>
b2f73e
Date: Fri, 27 Oct 2017 21:07:50 +0200
b2f73e
Subject: gdb-6.5-section-num-fixup-test.patch
b2f73e
b2f73e
;; Test a crash on libraries missing the .text section.
b2f73e
;;=fedoratest
b2f73e
b2f73e
diff --git a/gdb/testsuite/gdb.base/datalib-lib.c b/gdb/testsuite/gdb.base/datalib-lib.c
b2f73e
new file mode 100644
b2f73e
--- /dev/null
b2f73e
+++ b/gdb/testsuite/gdb.base/datalib-lib.c
b2f73e
@@ -0,0 +1,22 @@
b2f73e
+/* This testcase is part of GDB, the GNU debugger.
b2f73e
+
b2f73e
+   Copyright 2008 Free Software Foundation, Inc.
b2f73e
+
b2f73e
+   This program is free software; you can redistribute it and/or modify
b2f73e
+   it under the terms of the GNU General Public License as published by
b2f73e
+   the Free Software Foundation; either version 2 of the License, or
b2f73e
+   (at your option) any later version.
b2f73e
+
b2f73e
+   This program is distributed in the hope that it will be useful,
b2f73e
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
b2f73e
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b2f73e
+   GNU General Public License for more details.
b2f73e
+ 
b2f73e
+   You should have received a copy of the GNU General Public License
b2f73e
+   along with this program; if not, write to the Free Software
b2f73e
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
b2f73e
+
b2f73e
+   Please email any bugs, comments, and/or additions to this file to:
b2f73e
+   bug-gdb@prep.ai.mit.edu  */
b2f73e
+
b2f73e
+int var;
b2f73e
diff --git a/gdb/testsuite/gdb.base/datalib-main.c b/gdb/testsuite/gdb.base/datalib-main.c
b2f73e
new file mode 100644
b2f73e
--- /dev/null
b2f73e
+++ b/gdb/testsuite/gdb.base/datalib-main.c
b2f73e
@@ -0,0 +1,26 @@
b2f73e
+/* This testcase is part of GDB, the GNU debugger.
b2f73e
+
b2f73e
+   Copyright 2008 Free Software Foundation, Inc.
b2f73e
+
b2f73e
+   This program is free software; you can redistribute it and/or modify
b2f73e
+   it under the terms of the GNU General Public License as published by
b2f73e
+   the Free Software Foundation; either version 2 of the License, or
b2f73e
+   (at your option) any later version.
b2f73e
+
b2f73e
+   This program is distributed in the hope that it will be useful,
b2f73e
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
b2f73e
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b2f73e
+   GNU General Public License for more details.
b2f73e
+ 
b2f73e
+   You should have received a copy of the GNU General Public License
b2f73e
+   along with this program; if not, write to the Free Software
b2f73e
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
b2f73e
+
b2f73e
+   Please email any bugs, comments, and/or additions to this file to:
b2f73e
+   bug-gdb@prep.ai.mit.edu  */
b2f73e
+
b2f73e
+int
b2f73e
+main (void)
b2f73e
+{
b2f73e
+  return 0;
b2f73e
+}
b2f73e
diff --git a/gdb/testsuite/gdb.base/datalib.exp b/gdb/testsuite/gdb.base/datalib.exp
b2f73e
new file mode 100644
b2f73e
--- /dev/null
b2f73e
+++ b/gdb/testsuite/gdb.base/datalib.exp
b2f73e
@@ -0,0 +1,51 @@
b2f73e
+# Copyright 2008 Free Software Foundation, Inc.
b2f73e
+
b2f73e
+# This program is free software; you can redistribute it and/or modify
b2f73e
+# it under the terms of the GNU General Public License as published by
b2f73e
+# the Free Software Foundation; either version 2 of the License, or
b2f73e
+# (at your option) any later version.
b2f73e
+# 
b2f73e
+# This program is distributed in the hope that it will be useful,
b2f73e
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
b2f73e
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b2f73e
+# GNU General Public License for more details.
b2f73e
+# 
b2f73e
+# You should have received a copy of the GNU General Public License
b2f73e
+# along with this program; if not, write to the Free Software
b2f73e
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  
b2f73e
+
b2f73e
+set testfile datalib
b2f73e
+set srcfilemain ${testfile}-main.c
b2f73e
+set srcfilelib ${testfile}-lib.c
b2f73e
+set libfile [standard_output_file ${testfile}-lib.so]
b2f73e
+set binfile [standard_output_file ${testfile}-main]
b2f73e
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfilelib}" "${libfile}" executable [list debug {additional_flags=-shared -nostdlib}]] != "" } {
b2f73e
+    untested "Couldn't compile test program"
b2f73e
+    return -1
b2f73e
+}
b2f73e
+if  { [gdb_compile "${srcdir}/${subdir}/${srcfilemain}" "${binfile} ${libfile}" executable {debug}] != "" } {
b2f73e
+    untested "Couldn't compile test program"
b2f73e
+    return -1
b2f73e
+}
b2f73e
+
b2f73e
+# Get things started.
b2f73e
+
b2f73e
+gdb_exit
b2f73e
+gdb_start
b2f73e
+gdb_reinitialize_dir $srcdir/$subdir
b2f73e
+gdb_load ${binfile}
b2f73e
+
b2f73e
+# We must use a separate library as the main executable is compiled to the
b2f73e
+# address 0 by default and it would get fixed up already at the end of
b2f73e
+# INIT_OBJFILE_SECT_INDICES.  We also cannot PRELINK it as PRELINK is missing
b2f73e
+# on ia64.  The library must be NOSTDLIB as otherwise some stub code would
b2f73e
+# create the `.text' section there.  Also DEBUG option is useful as some of
b2f73e
+# the crashes occur in dwarf2read.c.
b2f73e
+
b2f73e
+# FAIL case:
b2f73e
+# ../../gdb/ia64-tdep.c:2838: internal-error: sect_index_text not initialized
b2f73e
+# A problem internal to GDB has been detected,
b2f73e
+
b2f73e
+gdb_test "start" \
b2f73e
+         "main \\(\\) at .*${srcfilemain}.*" \
b2f73e
+         "start"