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

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