Blame SOURCES/gdb-6.5-sharedlibrary-path.patch

132741
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
132741
From: Jan Kratochvil <jan.kratochvil@redhat.com>
132741
Date: Fri, 27 Oct 2017 21:07:50 +0200
132741
Subject: gdb-6.5-sharedlibrary-path.patch
132741
132741
;; Fix TLS symbols resolving for shared libraries with a relative pathname.
132741
;; The testsuite needs `gdb-6.5-tls-of-separate-debuginfo.patch'.
132741
;;=fedoratest: One should recheck if it is really fixed upstream.
132741
132741
If you provided some relative path to the shared library, such as with
132741
	export LD_LIBRARY_PATH=.
132741
then gdb would fail to match the shared library name during the TLS lookup.
132741
132741
Dropped the workaround/fix for gdb-6.8.50.20081128 - is it still needed?
132741
132741
The testsuite needs `gdb-6.3-bz146810-solib_absolute_prefix_is_empty.patch'.
132741
The testsuite needs `gdb-6.5-tls-of-separate-debuginfo.patch'.
132741
132741
2006-09-01  Jan Kratochvil  <jan.kratochvil@redhat.com>
132741
132741
	* solib-svr4.c (svr4_fetch_objfile_link_map): Match even absolute
132741
	requested pathnames to the internal loaded relative pathnames.
132741
132741
2007-10-16  Jan Kratochvil  <jan.kratochvil@redhat.com>
132741
132741
	Port to GDB-6.7.
132741
132741
2008-02-27  Jan Kratochvil  <jan.kratochvil@redhat.com>
132741
132741
	Port to gdb-6.7.50.20080227.
132741
132741
diff --git a/gdb/testsuite/gdb.threads/tls-sepdebug-main.c b/gdb/testsuite/gdb.threads/tls-sepdebug-main.c
132741
new file mode 100644
132741
--- /dev/null
132741
+++ b/gdb/testsuite/gdb.threads/tls-sepdebug-main.c
132741
@@ -0,0 +1,31 @@
132741
+/* This testcase is part of GDB, the GNU debugger.
132741
+
132741
+   Copyright 2006 Free Software Foundation, Inc.
132741
+
132741
+   This program is free software; you can redistribute it and/or modify
132741
+   it under the terms of the GNU General Public License as published by
132741
+   the Free Software Foundation; either version 2 of the License, or
132741
+   (at your option) any later version.
132741
+
132741
+   This program is distributed in the hope that it will be useful,
132741
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
132741
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
132741
+   GNU General Public License for more details.
132741
+
132741
+   You should have received a copy of the GNU General Public License
132741
+   along with this program; if not, write to the Free Software
132741
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
132741
+
132741
+   Please email any bugs, comments, and/or additions to this file to:
132741
+   bug-gdb@prep.ai.mit.edu  */
132741
+
132741
+#include <pthread.h>
132741
+
132741
+extern __thread int var;
132741
+
132741
+int main()
132741
+{
132741
+  /* Ensure we link against pthreads even with --as-needed.  */
132741
+  pthread_testcancel();
132741
+  return var;
132741
+}
132741
diff --git a/gdb/testsuite/gdb.threads/tls-sepdebug-shared.c b/gdb/testsuite/gdb.threads/tls-sepdebug-shared.c
132741
new file mode 100644
132741
--- /dev/null
132741
+++ b/gdb/testsuite/gdb.threads/tls-sepdebug-shared.c
132741
@@ -0,0 +1,22 @@
132741
+/* This testcase is part of GDB, the GNU debugger.
132741
+
132741
+   Copyright 2006 Free Software Foundation, Inc.
132741
+
132741
+   This program is free software; you can redistribute it and/or modify
132741
+   it under the terms of the GNU General Public License as published by
132741
+   the Free Software Foundation; either version 2 of the License, or
132741
+   (at your option) any later version.
132741
+
132741
+   This program is distributed in the hope that it will be useful,
132741
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
132741
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
132741
+   GNU General Public License for more details.
132741
+
132741
+   You should have received a copy of the GNU General Public License
132741
+   along with this program; if not, write to the Free Software
132741
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
132741
+
132741
+   Please email any bugs, comments, and/or additions to this file to:
132741
+   bug-gdb@prep.ai.mit.edu  */
132741
+
132741
+__thread int var = 42;
132741
diff --git a/gdb/testsuite/gdb.threads/tls-sepdebug.exp b/gdb/testsuite/gdb.threads/tls-sepdebug.exp
132741
new file mode 100644
132741
--- /dev/null
132741
+++ b/gdb/testsuite/gdb.threads/tls-sepdebug.exp
132741
@@ -0,0 +1,94 @@
132741
+# Copyright 2006 Free Software Foundation, Inc.
132741
+
132741
+# This program is free software; you can redistribute it and/or modify
132741
+# it under the terms of the GNU General Public License as published by
132741
+# the Free Software Foundation; either version 2 of the License, or
132741
+# (at your option) any later version.
132741
+#
132741
+# This program is distributed in the hope that it will be useful,
132741
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
132741
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
132741
+# GNU General Public License for more details.
132741
+#
132741
+# You should have received a copy of the GNU General Public License
132741
+# along with this program; if not, write to the Free Software
132741
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
132741
+
132741
+# This test uses gdb_exit and gdb_start, which are not supported
132741
+# on non-extended-remote sessions.
132741
+if {[use_gdb_stub]} {
132741
+    untested "skipping test because of stub"
132741
+    return 0
132741
+}
132741
+
132741
+if $tracelevel then {
132741
+    strace $tracelevel
132741
+}
132741
+
132741
+set testfile tls-sepdebug
132741
+set srcmainfile   ${testfile}-main.c
132741
+set srcsharedfile ${testfile}-shared.c
132741
+
132741
+set binmainfile        [standard_output_file ${testfile}-main]
132741
+set binsharedbase      ${testfile}-shared.so
132741
+set binsharedfile      [standard_output_file ${binsharedbase}]
132741
+set binshareddebugfile [standard_output_file ${binsharedbase}.debug]
132741
+
132741
+# Use explicit -soname as otherwise the full path to the library would get
132741
+# encoded into ${binmainfile} making LD_LIBRARY_PATH tests useless.
132741
+
132741
+# FIXME: gcc dependency (-Wl,-soname).
132741
+
132741
+if  { [gdb_compile_shlib "${srcdir}/${subdir}/${srcsharedfile}" "${binsharedfile}" [list debug additional_flags=-Wl,-soname=${binsharedbase}]] != "" } {
132741
+    untested "Couldn't compile test library"
132741
+    return -1
132741
+}
132741
+
132741
+# eu-strip(1) works fine but it is a part of `elfutils', not `binutils'.
132741
+if 0 then {
132741
+    remote_exec build "eu-strip -f ${binshareddebugfile} ${binsharedfile}"
132741
+} else {
132741
+    remote_exec build "objcopy --only-keep-debug ${binsharedfile} ${binshareddebugfile}"
132741
+    remote_exec build "objcopy --strip-debug ${binsharedfile}"
132741
+    remote_exec build "objcopy --add-gnu-debuglink=${binshareddebugfile} ${binsharedfile}"
132741
+}
132741
+
132741
+# Do not use `shlib=' as it will automatically add also -rpath for gcc.
132741
+
132741
+if  { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcmainfile} ${binsharedfile}" "${binmainfile}" executable {debug}] != "" } {
132741
+    untested "Couldn't compile test program"
132741
+    return -1
132741
+}
132741
+
132741
+# Get things started.
132741
+
132741
+# Test also the proper resolving of relative library names to absolute ones.
132741
+# \$PWD is easy - it is the absolute way
132741
+# ${subdir} would fail on "print var"
132741
+
132741
+set absdir [file dirname [standard_output_file ${binsharedbase}]]
132741
+foreach ld_library_path [list $absdir [relative_filename [pwd] $absdir]] name { absolute relative }  {
132741
+
132741
+    gdb_exit
132741
+    gdb_start
132741
+    ###gdb_reinitialize_dir $srcdir/$subdir
132741
+
132741
+    gdb_test "set env LD_LIBRARY_PATH=$ld_library_path" \
132741
+             "" \
132741
+             "set env LD_LIBRARY_PATH is $name"
132741
+
132741
+    gdb_load ${binmainfile}
132741
+
132741
+    # For C programs, "start" should stop in main().
132741
+
132741
+    gdb_test "start" \
132741
+             "main \\(\\) at .*${srcmainfile}.*" \
132741
+             "start"
132741
+
132741
+    # Check for: Cannot find shared library `/usr/lib/debug/lib/libc-2.4.90.so.debug' in dynamic linker's load module list
132741
+    # as happens with TLS variables and `separate_debug_objfile_backlink'.
132741
+
132741
+    gdb_test "print var" \
132741
+             "\\\$1 = \[0-9\].*" \
132741
+             "print TLS variable from a shared library with $name-directory separate debug info file"
132741
+}