This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] PR ld/17618: Check PC-relative offset overflow in PLT entry
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Hans-Peter Nilsson <hans-peter dot nilsson at axis dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Sat, 21 Oct 2017 12:17:23 -0700
- Subject: Re: [PATCH] PR ld/17618: Check PC-relative offset overflow in PLT entry
- Authentication-results: sourceware.org; auth=none
- References: <CAMe9rOoaNMRquPCwPof+j__MT1vCUcqu9rSm2iLLNDHij5MaDw@mail.gmail.com> <201710211834.v9LIYx3o014432@ignucius.se.axis.com>
On Sat, Oct 21, 2017 at 11:34 AM, Hans-Peter Nilsson
<hans-peter.nilsson@axis.com> wrote:
>> 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?
>
It checks if linker can support 64-bit address space, which
is independent of bfd-size. Some tests require that linker
supports 64-bit address.
--
H.J.