aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2025-07-18 09:10:35 -0400
committerSimon Marchi <simon.marchi@efficios.com>2025-08-22 10:45:47 -0400
commit33b761b201573a6e945b1148d5e965a580f129b1 (patch)
tree7ab5bc770b5d3ca3144317dda4262969d2787ca8
parent858ed9bfe38682274cfa58948c79d4854abd80c4 (diff)
downloadbinutils-33b761b201573a6e945b1148d5e965a580f129b1.zip
binutils-33b761b201573a6e945b1148d5e965a580f129b1.tar.gz
binutils-33b761b201573a6e945b1148d5e965a580f129b1.tar.bz2
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 <guinevere@redhat.com>
-rw-r--r--gdb/testsuite/gdb.base/dlmopen.exp12
-rw-r--r--gdb/testsuite/gdb.mi/mi-dlmopen.exp12
2 files changed, 22 insertions, 2 deletions
diff --git a/gdb/testsuite/gdb.base/dlmopen.exp b/gdb/testsuite/gdb.base/dlmopen.exp
index e7bf6f3..cdc4910 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 c0208eb..fa7e373 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