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

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