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

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