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: GOLD handling of weak symbols (including x86 vs. ARM)


Richard Sandiford <richard.sandiford@linaro.org> writes:

> Unfortunately, just removing:
>
>  Â Âif (this->is_weak_undefined())
>  Â Â Âreturn true;
>
> regresses weak_plt on x86_64.  We rely completely on use_plt_offset() to
> determine whether a relocation uses a PLT, so removing the check means
> that even:
>
> 	call    foo@PLT
>
> won't use a PLT for a weak undefined foo in executables.  (Recall that
> BFD LD does use a PLT in this case, and rightly so.)
>
> What I found a little confusing is that use_plt_offset() unconditionally
> passes FUNCTION_CALL to needs_dynamic_reloc(), even though most calls to
> use_plt_offset() are made for all relocation types, not just branch/call
> relocations.  Is FUNCTION_CALL supposed to mean something else in this
> context?
>
> Perhaps we should turn the use_plt_offset() argument into the same
> Reference_flags set as needs_dynamic_reloc(), then get the callers of
> use_plt_offset() to set FUNCTION_CALL only for branch/call relocs.
> That would let us restrict:
>
>  Â Âif (this->is_weak_undefined())
>  Â Â Âreturn true;
>
> to cases where FUNCTION_CALL is set.  Unfortunately, this will touch
> all backends, so I thought I'd better ask for comments before coding it up.

use_plt_offset is only meaningful when there actually is a PLT.  A
backend like i386.cc sets FUNCTION_CALL when calling needs_dynamic_reloc
for any symbol with type STT_FUNC.  Only STT_FUNC symbols get PLT
offsets.  So at least for the i386 backend it will always be appropriate
to pass FUNCTION_CALL from use_plt_offset to needs_dynamic_reloc.  There
is no case in which the flag should not be set.

The ARM backend does not appear to ever set FUNCTION_CALL when calling
needs_dynamic_reloc.  I'm not sure why.

In other words, FUNCTION_CALL isn't used to mean a relocation which is a
function call.  It means a symbol which is a function.  It should
probably be renamed to IS_FUNCTION.  Or just omitted, and
needs_dynamic_reloc can check the symbol type itself.

It seems to me that the distinguishing characteristic of "foo@PLT" is
not that it is a function call, it is that the relocation specifically
requires the PLT.  I suspect that the right thing to do here is to
always use the use the PLT offset, if there is one, for R_386_PLT32.

Ian


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