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

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