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

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