]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb/testsuite: handle dynamic linker path with symlink in dlmopen tests
authorSimon Marchi <simon.marchi@efficios.com>
Fri, 18 Jul 2025 13:10:35 +0000 (09:10 -0400)
committerSimon Marchi <simon.marchi@efficios.com>
Fri, 22 Aug 2025 14:45:47 +0000 (10:45 -0400)
On my Arch Linux system*, the dynamic linker path specified in ELF
binaries contains a symlink:

    $ readelf --program-headers /bin/ls | grep "Requesting program interpreter"
          [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
    $ ls -l /lib64
    lrwxrwxrwx 1 root root 7 May  3 15:26 /lib64 -> usr/lib
    $ realpath /lib64/ld-linux-x86-64.so.2
    /usr/lib/ld-linux-x86-64.so.2

Because of this, some dlmopen tests think that the dynamic linker
doesn't appear multiple times, when it in fact does (under two different
names), and some parts of the test are disabled:

    UNSUPPORTED: gdb.base/dlmopen.exp: test_solib_unmap_events: multiple copies of the dynamic linker not found

Make the tests compute the real path of the dynamic linker and accept
that as valid path for the dynamic linker.

With this patch, I go from

    # of expected passes            92

to

    # of expected passes            98

* On my Ubuntu 24.04 system, the dynamic linker appears to be a symlink
  too, but the glibc is too old to show the dynamic linker in the
  non-default namespace.

Change-Id: I03867f40e5313816bd8a8401b65713ddef5d620e
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
gdb/testsuite/gdb.base/dlmopen.exp
gdb/testsuite/gdb.mi/mi-dlmopen.exp

index e7bf6f3f7bc59b7565e96a8c1a2221b39b0e92e7..cdc49100e4c256e336380e6834d3cd6945e9036a 100644 (file)
@@ -95,9 +95,19 @@ if { $dyln_name eq "" } {
     return
 }
 
+# If the dynamic linker path contains a symlink, some instances show the real
+# path instead of the original path.  Accept both.
+lassign [remote_exec target realpath "$dyln_name"] realpath_ret dyln_realpath_name
+
+if { $realpath_ret == 0 } {
+    set dyln_realpath_name [string trim $dyln_realpath_name]
+} else {
+    set dyln_realpath_name "not-a-valid-path"
+}
+
 # Return true if FILENAME is the dynamic linker.  Otherwise return false.
 proc is_dyln { filename } {
-    return [expr {$filename eq $::dyln_name}]
+    return [expr {$filename eq $::dyln_name || $filename eq $::dyln_realpath_name}]
 }
 
 # Check that 'info shared' show NUM occurrences of DSO.
index c0208ebcc5132e872c4dce593aa159997e54b486..fa7e3731f4a1c4dd7ba133e737a4f5f630e06c1a 100644 (file)
@@ -65,9 +65,19 @@ if { $dyln_name eq "" } {
 set bp_main [gdb_get_line_number "bp.main" $srcfile]
 set bp_loaded [gdb_get_line_number "bp.loaded" $srcfile]
 
+# If the dynamic linker path contains a symlink, some instances show the real
+# path instead of the original path.  Accept both.
+lassign [remote_exec target realpath "$dyln_name"] realpath_ret dyln_realpath_name
+
+if { $realpath_ret == 0 } {
+    set dyln_realpath_name [string trim $dyln_realpath_name]
+} else {
+    set dyln_realpath_name "not-a-valid-path"
+}
+
 # Return true if FILENAME is the dynamic linker.  Otherwise return false.
 proc is_dyln { filename } {
-    return [expr {$filename eq $::dyln_name}]
+    return [expr {$filename eq $::dyln_name || $filename eq $::dyln_realpath_name}]
 }
 
 # Run 'info sharedlibrary' and count the number of mappings that look