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

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