[PATCH] gold: Ignore definition from a dynamic object for __start/__stop

Cary Coutant ccoutant@gmail.com
Wed Nov 8 23:50:00 GMT 2017


+   // Skip if the old definition is from a regular object.
+   if (!oldsym->is_from_dynobj())
+     return NULL;
+
+   // If the symbol has the hidden or internal visibility, ignore
+   // definition and reference from a dynamic object.
+   if ((visibility == elfcpp::STV_HIDDEN
+        || visibility == elfcpp::STV_INTERNAL)
+       && !oldsym->in_reg())

s/the hidden/hidden/

The last if statement really just ignores the symbol if it hasn't been
referenced in a regular object. The first if statement takes care of
the case where the definition was in a dynamic object.

OK with updated comment.

Thanks!

-cary


On Fri, Oct 20, 2017 at 1:39 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
> On Fri, Oct 20, 2017 at 11:50 AM, H.J. Lu <hjl.tools@gmail.com> wrote:
>> On Fri, Oct 20, 2017 at 11:11 AM, Cary Coutant <ccoutant@gmail.com> wrote:
>>>>> I think the must_be_in_reg flag is unnecessary -- only_if_ref should
>>>>> be sufficient. I looked through all the symbols that are created with
>>>>
>>>> As Alan mentioned, __start and __stop symbols must be exported,
>>>> but not preempted.  STV_PROTECTED should be used.
>>>>
>>>>> only_if_ref true, and they all look like they should ignore
>>>>> definitions (and references) in dynamic objects:
>>>>>
>>>>>   __rel_iplt_start (global hidden)
>>>>>   __rel_iplt_end (global hidden)
>>>>>  __exidx_start (arm, global hidden)
>>>>>   __exidx_end (arm, global hidden)
>>>>>   _TLS_MODULE_BASE_ (local hidden)
>>>>>   __preinit_array_start (global hidden)
>>>>>   __preinit_array_end (global hidden)
>>>>>   __init_array_start (global hidden)
>>>>>   __init_array_end (global hidden)
>>>>>   __fini_array_start (global hidden)
>>>>>   __fini_array_end (global hidden)
>>>>>   __stack (global default)
>>>>>   __executable_start (global default)
>>>>>   __ehdr_start (global hidden)
>>>>>   etext, _etext, __etext (global default)
>>>>>   edata (global default)
>>>>>   end (global default)
>>>>>
>>>>> Certainly the ones that are hidden should ignore both defs and refs in
>>>>> dynamic objects. The others (__stack, __executable_start, [_][_]etext,
>>>>> edata, and end) should at least ignore defs in dynamic objects.
>>>
>>> You didn't answer why you think it's not reasonable to use only_if_ref
>>> by itself, rather than adding the new must_be_in_reg flag.
>>>
>>
>> only_if_ref isn't sufficient.  Passing visibility to define_special_symbol
>> may work.  If visibility != STV_DEFAULT, both refs and defs in dynamic
>> objects can be ignored.  If visibility == STV_DEFAULT, defs in dynamic
>> objects can be ignored.
>>
>
> Here is the updated patch.
>
> --
> H.J.



More information about the Binutils mailing list