This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [PATCH] gold: Ignore definition from a dynamic object for __start/__stop
- From: Cary Coutant <ccoutant at gmail dot com>
- To: "H.J. Lu" <hjl dot tools at gmail dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Wed, 8 Nov 2017 15:50:11 -0800
- Subject: Re: [PATCH] gold: Ignore definition from a dynamic object for __start/__stop
- Authentication-results: sourceware.org; auth=none
- References: <20171018132021.GA4627@gmail.com> <CAJimCsEYhYtcPosB6vjsUsp02G69KKgn3MZ9=a=5XUowcx6diA@mail.gmail.com> <CAMe9rOoC=tOzrQJwdY=esUJpyE4n5d19NKLRutk066F9SJHMtg@mail.gmail.com> <CAJimCsFQiqTWALj4F8Ko7b_PhNuyFUqc8PmUW-5KGpD-kDD5eA@mail.gmail.com> <CAMe9rOqiJ4s9+oWM6XpL=r3cawTDR+o1Myn9nargOiN+_pNq9g@mail.gmail.com> <CAMe9rOq0TrC=2Rtqr+bVktdOrdH5zzz04Mw_ojTieub9sGmZVA@mail.gmail.com>
+ // 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.