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

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