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

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