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

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