This is the mail archive of the 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: [RFC][PATCH] Check ELF relocs after opening all all input files

On Wed, Apr 20, 2016 at 5:39 PM, H.J. Lu <> wrote:
> On Tue, Apr 19, 2016 at 4:24 PM, Alan Modra <> wrote:
>> On Tue, Apr 19, 2016 at 11:03:15AM -0700, H.J. Lu wrote:
>>> On Tue, Apr 19, 2016 at 9:01 AM, Nick Clifton <> wrote:
>>> > Hi H.J.
>>> >
>>> >> Delaying checking ELF relocations until opening all input files so
>>> >> that symbol information is final when relocations are checked.  This
>>> >> is only enabled for x86 targets.
>>> >
>>> >> Any comments, feedbacks?
>>> >
>>> > What benefit is gained by doing this ?  I would guess that it is connected
>>> > with symbols changing type and/or visibility and/or protected status, but
>>> > it would be nice to know what you are hoping to achieve.
>>> Yes,  this change is motivated by that discussion.  Currently backend
>>> check_relocs doesn't have the final information on symbols.  A better
>>> linker can provide better diagnostics in check_relocs if symbol info is
>>> final.
>> There are other benefits too.  As it is the backend check_relocs
>> functions do things like "maybe this symbol remains undefined so
>> perhaps it needs a plt entry", and "maybe this symbol remains dynamic
>> so perhaps it needs dynamic relocations".  This complexity can
>> disappear if all of those "maybe" cases are resolved.
> The first phase of x86 backend is done.  I will take a look to see if I can
> remove some checks in x86 check_relocs when I have time.
>> Now, if you run check_relocs even later, say at
>> ldemul_before_allocation, after gc-sections has run, then all the
>> reference counting code for plt and got relocs can be removed too.
> I  checked in:
> commit e66cdd681f47dc51beaeee3d813f1c9cba27dedf
> Author: H.J. Lu <>
> Date:   Wed Apr 20 17:12:46 2016 -0700
>     Remove x86 gc_sweep_hook
>     Since x86 backends never see the removed sections, there is no need
>     for gc_sweep_hook.
>       * elf32-i386.c (elf_i386_gc_sweep_hook): Removed.
>       (elf_backend_gc_sweep_hook): Likewise.
>       * elf64-x86-64.c (elf_x86_64_gc_sweep_hook): Likewise.
>       (elf_backend_gc_sweep_hook): Likewise.
> Other reference counting code for plt and got relocs in x86 backend
> has to stay for TLS optimization and GOT/PLT optimization.

Another problem is when check_relocs is run, linker defined symbols
haven't been processed yet.


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