[RFC][PATCH] Check ELF relocs after opening all all input files
H.J. Lu
hjl.tools@gmail.com
Thu Apr 28 17:11:00 GMT 2016
On Thu, Apr 28, 2016 at 6:40 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Thu, Apr 28, 2016 at 6:09 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Thu, Apr 28, 2016 at 6:07 AM, Alan Modra <amodra@gmail.com> wrote:
>>> On Thu, Apr 28, 2016 at 05:49:57AM -0700, H.J. Lu wrote:
>>>> On Wed, Apr 27, 2016 at 6:11 PM, Alan Modra <amodra@gmail.com> wrote:
>>>> > On Wed, Apr 27, 2016 at 03:24:48PM -0700, H.J. Lu wrote:
>>>> >> bfd_elf_record_link_assignment
>>>> >> is called after check_relocs. bfd_elf_record_link_assignment sets non_elf,
>>>> >> def_regular and forced_local. For PROVIDE, it also updates root.type. They
>>>> >> are needed in reloc_checks.
>>>> >
>>>> > My guess is that symbol twiddling done in before_allocation should be
>>>> > moved to a new ldemul hook called at the start of lang_do_assignments.
>>>> > The idea being to stabilize symbols earlier.
>>>> >
>>>> > The hook would twiddle __ehdr_start and call find_statement_assignment
>>>> > when lang_mark_phase_enum. Reversing the __ehdr_start twiddle stays
>>>> > in before_allocation.
>>>> >
>>>>
>>>> I tried this. But it doesn't work with __start/__stop symbols. I
>>>> need to know if they are defined and referenced local in check_relocs.
>>> [snip]
>>>
>>>> --- a/ld/ldlang.c
>>>> +++ b/ld/ldlang.c
>>>> @@ -6930,6 +6930,8 @@ lang_process (void)
>>>> collection in order to make sure that all symbol aliases are resolved. */
>>>> lang_do_assignments (lang_mark_phase_enum);
>>>>
>>>> + ldemul_record_link_assignments (lang_mark_phase_enum);
>>>> +
>>>> lang_do_memory_regions();
>>>> expld.phase = lang_first_phase_enum;
>>>
>>> You'll need to run ldemul_record_link_assignments before
>>> lang_do_assignments if you want provided symbols to be defined.
>>
>> I got many more failures when I did that since many assignments
>> haven't been processed yet.
>>
>>> I suggest renaming to ldemul_do_assignments and putting
>>> ldemul_do_assignments (phase);
>>> inside lang_do_assignments just before the call to
>>> lang_do_assignments_1.
>>>
>
> With this patch, I only got 2 failures on x86-64.
>
This one works for both i386 and x86-64.
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Add-_bfd_elf_record_start_stop.patch
Type: text/x-patch
Size: 4843 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20160428/ec5f66e4/attachment.bin>
More information about the Binutils
mailing list