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

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