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

Message ID 20240622100557.10155-1-xry111@xry111.site
State New
Headers
Series ld: testsuite: Add a bootstrap test using -Wl, -z, pack-relative-relocs if DT_RELR supported |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 fail Test failed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

Xi Ruoyao June 22, 2024, 10:05 a.m. UTC
  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(-)
  

Comments

Xi Ruoyao June 23, 2024, 1:06 a.m. UTC | #1
On Sat, 2024-06-22 at 18:05 +0800, Xi Ruoyao wrote:
> This helps to test the correctness of DT_RELR.
> 
> Signed-off-by: Xi Ruoyao <xry111@xry111.site>

The patch is dropped because it won't work with old Glibc.

> ---
>  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 ""
>      }
>
  

Patch

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 ""
     }