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

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