This is the mail archive of the binutils@sourceware.org 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: gold regression vs BFD ld: __ehdr_start


That's extremely similar to what I was just writing myself.
I had a different (and possibly infeasible) idea for the behavior in
the case when it can't be defined.
That is, to morph it into an actually undefined symbol.

What would yours do in case of weak references to __ehdr_start when it
cannot be defined?

On Mon, Mar 31, 2014 at 2:03 PM, Cary Coutant <ccoutant@google.com> wrote:
>>> I think what has to happen is something analogous to what BFD ld does now:
>>> Add the symbol early on in an undefined or indeterminate state, and then
>>> define it (or don't) later on.  It's not very clear to me how to do that
>>> correctly in gold.  It would seem clearest if it can be done in
>>> define_standard_symbols.  But I don't know what Layout::finalize (where
>>> it's created now) should do to find it and adjust it to point at the right
>>> segment.  I also don't know how either case would interact with a user
>>> defining (in input or script) this symbol name himself, in which case (IIRC
>>> the BFD ld behavior) the user's symbol should be wholly unmolested (but it
>>> might be that BFD ld uses the user's value but marks it STV_HIDDEN
>>> anyway--I'm not sure).
>>
>> I don't know why __ehdr_start is defined in Layout::finalize.  As you
>> suggest, it should be defined by define_standard_symbols instead,
>> setting the only_if_ref field to true.  If necessary, Layout::finalize
>> can adjust the symbol value using init_output_segment, but only if the
>> symbol is marked as predefined.  Layout::finalize can simply look up
>> the symbol by name.
>
> The attached patch should fix this. Can you give it a try, and if it
> works, I'll add a testcase and check it in.
>
> -cary
>
> 2014-03-31  Cary Coutant  <ccoutant@google.com>
>
>         * gold/defstd.cc (in_segment): Define __ehdr_start here...
>         * gold/layout.cc (Layout::finalize): ...Instead of here.  Set the
>         output segment when known.
>         * gold/symtab.cc (Symbol::set_output_segment): New function.
>         * gold/symtab.h (Symbol::set_output_segment): New function.


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