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

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