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

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