This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] PR ld/17618: Check PC-relative offset overflow in PLT entry


> From: "H.J. Lu" <hjl.tools@gmail.com>
> Date: Wed, 9 Aug 2017 15:08:54 -0700

> PR ld/17618 test requires 64-bit linker to run.  Set LD_CLASS to "64bit"
> for 64-bit ELF linker and run PR ld/17618 test only if $LD_CLASS is
> "64bit".  More checks can be added to support 64-bit linkers in non-ELF
> format.
> 
> 	  * testsuite/config/default.exp (LD_CLASS): New.  Set to "64bit"
> 	  for 64-bit ELF linker.
> 	  * testsuite/ld-x86-64/pr17618.d (#notarget): Removed.
> 	  * testsuite/ld-x86-64/x86-64.exp: Run pr17618 only for 64-bit
> 	  linker.

> diff --git a/ld/testsuite/config/default.exp b/ld/testsuite/config/default.exp
> index f5cb188478..355d98f24a 100644
> --- a/ld/testsuite/config/default.exp
> +++ b/ld/testsuite/config/default.exp
> @@ -251,6 +251,16 @@ if ![info exists LDFLAGS] then {
>      set LDFLAGS {}
>  }
>  
> +# Set LD_CLASS to "64bit" for 64-bit LD.
> +if { ![info exists LD_CLASS] } then {
> +    set readelf_output [run_host_cmd "$READELF" "-h $LD"]

(later changed LD to REAL_LD, but that doesn't solve the issue
pointed out below)

> +    if { [regexp {[ \t]+Class:[ \t]+ELF64} $readelf_output] } then {
> +	set LD_CLASS "64bit"
> +    } else {
> +	set LD_CLASS "32bit"
> +    }
> +}
> +

This method was suggested in PR ld/22304 as a help.  It's not
actually applicable there, but it's the reason I'm looking.

This looks like it has a bug.  You're looking at the "ELF class"
for the ld being built, which is not necessarily a program that
will run on the target; it will "only" work for native builds.
A trivial suggestion is to link some simple object and inspect
that result (instead of the ld tool).  If you really want the
host "ELF class" of the toolchain (which also has some value), I
think it should be called "BUILD_ELF_CLASS".  Note also that
either can be completely different from the "bfd-size";
i.e. whether --enable-64-bit-bfd has been explicitly or
implicitly used.

Unless I miss something?

(I don't care to mention Canadian crosses here, i.e. build !=
host != target, because then I'd surely confuse myself.)

brgds, H-P


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]