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

7bc85d
From FEDORA_PATCHES Mon Sep 17 00:00:00 2001
7bc85d
From: Jan Kratochvil <jan.kratochvil@redhat.com>
7bc85d
Date: Fri, 27 Oct 2017 21:07:50 +0200
7bc85d
Subject: gdb-6.5-sharedlibrary-path.patch
7bc85d
7bc85d
;; Fix TLS symbols resolving for shared libraries with a relative pathname.
7bc85d
;; The testsuite needs `gdb-6.5-tls-of-separate-debuginfo.patch'.
7bc85d
;;=fedoratest: One should recheck if it is really fixed upstream.
7bc85d
7bc85d
If you provided some relative path to the shared library, such as with
7bc85d
	export LD_LIBRARY_PATH=.
7bc85d
then gdb would fail to match the shared library name during the TLS lookup.
7bc85d
7bc85d
Dropped the workaround/fix for gdb-6.8.50.20081128 - is it still needed?
7bc85d
7bc85d
The testsuite needs `gdb-6.3-bz146810-solib_absolute_prefix_is_empty.patch'.
7bc85d
The testsuite needs `gdb-6.5-tls-of-separate-debuginfo.patch'.
7bc85d
7bc85d
2006-09-01  Jan Kratochvil  <jan.kratochvil@redhat.com>
7bc85d
7bc85d
	* solib-svr4.c (svr4_fetch_objfile_link_map): Match even absolute
7bc85d
	requested pathnames to the internal loaded relative pathnames.
7bc85d
7bc85d
2007-10-16  Jan Kratochvil  <jan.kratochvil@redhat.com>
7bc85d
7bc85d
	Port to GDB-6.7.
7bc85d
7bc85d
2008-02-27  Jan Kratochvil  <jan.kratochvil@redhat.com>
7bc85d
7bc85d
	Port to gdb-6.7.50.20080227.
7bc85d
7bc85d
diff --git a/gdb/testsuite/gdb.threads/tls-sepdebug-main.c b/gdb/testsuite/gdb.threads/tls-sepdebug-main.c
7bc85d
new file mode 100644
7bc85d
--- /dev/null
7bc85d
+++ b/gdb/testsuite/gdb.threads/tls-sepdebug-main.c
7bc85d
@@ -0,0 +1,25 @@
7bc85d
+/* This testcase is part of GDB, the GNU debugger.
7bc85d
+
7bc85d
+   Copyright 2006 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 main()
7bc85d
+{
7bc85d
+  return 0;
7bc85d
+}
7bc85d
diff --git a/gdb/testsuite/gdb.threads/tls-sepdebug-shared.c b/gdb/testsuite/gdb.threads/tls-sepdebug-shared.c
7bc85d
new file mode 100644
7bc85d
--- /dev/null
7bc85d
+++ b/gdb/testsuite/gdb.threads/tls-sepdebug-shared.c
7bc85d
@@ -0,0 +1,22 @@
7bc85d
+/* This testcase is part of GDB, the GNU debugger.
7bc85d
+
7bc85d
+   Copyright 2006 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
+__thread int var = 42;
7bc85d
diff --git a/gdb/testsuite/gdb.threads/tls-sepdebug.exp b/gdb/testsuite/gdb.threads/tls-sepdebug.exp
7bc85d
new file mode 100644
7bc85d
--- /dev/null
7bc85d
+++ b/gdb/testsuite/gdb.threads/tls-sepdebug.exp
7bc85d
@@ -0,0 +1,87 @@
7bc85d
+# Copyright 2006 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
+if $tracelevel then {
7bc85d
+    strace $tracelevel
7bc85d
+}
7bc85d
+
7bc85d
+set testfile tls-sepdebug
7bc85d
+set srcmainfile   ${testfile}-main.c
7bc85d
+set srcsharedfile ${testfile}-shared.c
7bc85d
+
7bc85d
+set binmainfile        [standard_output_file ${testfile}-main]
7bc85d
+set binsharedbase      ${testfile}-shared.so
7bc85d
+set binsharedfile      [standard_output_file ${binsharedbase}]
7bc85d
+set binshareddebugfile [standard_output_file ${binsharedbase}.debug]
7bc85d
+
7bc85d
+# Use explicit -soname as otherwise the full path to the library would get
7bc85d
+# encoded into ${binmainfile} making LD_LIBRARY_PATH tests useless.
7bc85d
+
7bc85d
+# FIXME: gcc dependency (-Wl,-soname).
7bc85d
+
7bc85d
+if  { [gdb_compile_shlib "${srcdir}/${subdir}/${srcsharedfile}" "${binsharedfile}" [list debug additional_flags=-Wl,-soname=${binsharedbase}]] != "" } {
7bc85d
+    untested "Couldn't compile test library"
7bc85d
+    return -1
7bc85d
+}
7bc85d
+
7bc85d
+# eu-strip(1) works fine but it is a part of `elfutils', not `binutils'.
7bc85d
+if 0 then {
7bc85d
+    remote_exec build "eu-strip -f ${binshareddebugfile} ${binsharedfile}"
7bc85d
+} else {
7bc85d
+    remote_exec build "objcopy --only-keep-debug ${binsharedfile} ${binshareddebugfile}"
7bc85d
+    remote_exec build "objcopy --strip-debug ${binsharedfile}"
7bc85d
+    remote_exec build "objcopy --add-gnu-debuglink=${binshareddebugfile} ${binsharedfile}"
7bc85d
+}
7bc85d
+
7bc85d
+# Do not use `shlib=' as it will automatically add also -rpath for gcc.
7bc85d
+
7bc85d
+if  { [gdb_compile_pthreads "${srcdir}/${subdir}/${srcmainfile} ${binsharedfile}" "${binmainfile}" executable {debug}] != "" } {
7bc85d
+    untested "Couldn't compile test program"
7bc85d
+    return -1
7bc85d
+}
7bc85d
+
7bc85d
+# Get things started.
7bc85d
+
7bc85d
+# Test also the proper resolving of relative library names to absolute ones.
7bc85d
+# \$PWD is easy - it is the absolute way
7bc85d
+# ${subdir} would fail on "print var"
7bc85d
+
7bc85d
+set absdir [file dirname [standard_output_file ${binsharedbase}]]
7bc85d
+foreach ld_library_path [list $absdir [relative_filename [pwd] $absdir]] name { absolute relative }  {
7bc85d
+
7bc85d
+    gdb_exit
7bc85d
+    gdb_start
7bc85d
+    ###gdb_reinitialize_dir $srcdir/$subdir
7bc85d
+    
7bc85d
+    gdb_test "set env LD_LIBRARY_PATH=$ld_library_path" \
7bc85d
+             "" \
7bc85d
+             "set env LD_LIBRARY_PATH is $name"
7bc85d
+    
7bc85d
+    gdb_load ${binmainfile}
7bc85d
+    
7bc85d
+    # For C programs, "start" should stop in main().
7bc85d
+    
7bc85d
+    gdb_test "start" \
7bc85d
+             "main \\(\\) at .*${srcmainfile}.*" \
7bc85d
+             "start"
7bc85d
+    
7bc85d
+    # Check for: Cannot find shared library `/usr/lib/debug/lib/libc-2.4.90.so.debug' in dynamic linker's load module list
7bc85d
+    # as happens with TLS variables and `separate_debug_objfile_backlink'.
7bc85d
+    
7bc85d
+    gdb_test "print var" \
7bc85d
+             "\\\$1 = \[0-9\].*" \
7bc85d
+             "print TLS variable from a shared library with $name-directory separate debug info file"
7bc85d
+}