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