[PATCH] ld: testsuite: Add a bootstrap test using -Wl, -z, pack-relative-relocs if DT_RELR supported

Xi Ruoyao xry111@xry111.site
Sat Jun 22 10:05:57 GMT 2024


This helps to test the correctness of DT_RELR.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
---
 ld/testsuite/ld-bootstrap/bootstrap.exp | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/ld/testsuite/ld-bootstrap/bootstrap.exp b/ld/testsuite/ld-bootstrap/bootstrap.exp
index 437a3bc6842..2eaae3a0d45 100644
--- a/ld/testsuite/ld-bootstrap/bootstrap.exp
+++ b/ld/testsuite/ld-bootstrap/bootstrap.exp
@@ -69,6 +69,9 @@ if { [istarget "powerpc-*-*"] } {
 if { [is_elf_format] && ![is_bad_symtab] } {
     lappend test_flags "-Wl,-z,nosectionheader"
 }
+if { [supports_dt_relr] } then {
+    lappend test_flags "-Wl,-z,pack-relative-relocs"
+}
 
 set gcc_B_opt_save $gcc_B_opt
 
@@ -97,12 +100,13 @@ foreach flags $test_flags {
 	set testname "bootstrap"
     }}
 
-    # --static is meaningless.  --relax and -z nosectionheader are
-    # incompatible with -r.
+    # --static is meaningless.  --relax, -z nosectionheader, and
+    # -z pack-relative-relocs are incompatible with -r.
     regsub -- "-Wl," $flags "" partial_flags
     if { "$partial_flags" == "--static" \
 	 || "$partial_flags" == "--relax" \
-	 || [string match "*nosectionheader*" "$partial_flags"] } {
+	 || [string match "*nosectionheader*" "$partial_flags"]
+	 || [string match "*pack-relative-relocs*" "$partial_flags"] } {
 	set partial_flags ""
     }
 
-- 
2.45.2



More information about the Binutils mailing list