[PATCH] ld: Lookup section in output with the same name
H.J. Lu
hjl.tools@gmail.com
Fri Aug 31 15:50:00 GMT 2018
On Fri, Aug 31, 2018 at 8:39 AM, Alan Modra <amodra@gmail.com> wrote:
> On Thu, Aug 30, 2018 at 01:51:37PM -0700, H.J. Lu wrote:
>> --- a/ld/ldlang.c
>> +++ b/ld/ldlang.c
>> @@ -6097,6 +6097,24 @@ undef_start_stop (struct bfd_link_hash_entry *h)
>> || strcmp (h->u.def.section->name,
>> h->u.def.section->output_section->name) != 0)
>> {
>> + asection *sec = bfd_get_section_by_name (link_info.output_bfd,
>> + h->u.def.section->name);
>> + if (sec != NULL)
>> + {
>> + /* When there are more than one input sections with the same
>> + section name, SECNAME, linker picks the first one to define
>> + __start_SECNAME and __stop_SECNAME symbols. When the first
>> + input section is removed by comdat group, we need to check
>> + if there is still an output section with section name
>> + SECNAME. */
>> + asection *i;
>> + for (i = sec->map_head.s; i != NULL; i = i->map_head.s)
>> + if (i->size != 0)
>
> I think you should check that i->name matches h->u.def.section->name
> here. At one stage we only defined start/stop symbols on orphans,
> but now we do so whenever input section name matches output section
> name and the name is alphanumeric. That means a linker script might
> be involved in which case differently named input sections might map
> to the output section.
>
> Also, why do you check i->size? We define start/stop symbols on zero
> sized sections!
Like this?
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-ld-Lookup-section-in-output-with-the-same-name.patch
Type: text/x-patch
Size: 4244 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20180831/adbf2137/attachment.bin>
More information about the Binutils
mailing list