From: Simon Marchi Date: Fri, 18 Jul 2025 13:10:35 +0000 (-0400) Subject: gdb/testsuite: handle dynamic linker path with symlink in dlmopen tests X-Git-Tag: gdb-17-branchpoint~220 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=33b761b201573a6e945b1148d5e965a580f129b1;p=thirdparty%2Fbinutils-gdb.git gdb/testsuite: handle dynamic linker path with symlink in dlmopen tests 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 --- diff --git a/gdb/testsuite/gdb.base/dlmopen.exp b/gdb/testsuite/gdb.base/dlmopen.exp index e7bf6f3f7bc..cdc49100e4c 100644 --- a/gdb/testsuite/gdb.base/dlmopen.exp +++ b/gdb/testsuite/gdb.base/dlmopen.exp @@ -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. diff --git a/gdb/testsuite/gdb.mi/mi-dlmopen.exp b/gdb/testsuite/gdb.mi/mi-dlmopen.exp index c0208ebcc51..fa7e3731f4a 100644 --- a/gdb/testsuite/gdb.mi/mi-dlmopen.exp +++ b/gdb/testsuite/gdb.mi/mi-dlmopen.exp @@ -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