This is the mail archive of the
mailing list for the binutils project.
Re: gold regression vs BFD ld: __ehdr_start
- From: Roland McGrath <mcgrathr at google dot com>
- To: Cary Coutant <ccoutant at google dot com>
- Cc: Ian Lance Taylor <iant at google dot com>, Roland McGrath <roland at hack dot frob dot com>, Binutils <binutils at sourceware dot org>
- Date: Mon, 31 Mar 2014 14:06:39 -0700
- Subject: Re: gold regression vs BFD ld: __ehdr_start
- Authentication-results: sourceware.org; auth=none
- References: <20140330011513 dot D6435744AE at topped-with-meat dot com> <CAKOQZ8x2Aj3reAZKyEAAKKjcFFTu7KZY01WwXCHiOD0WLQC=_g at mail dot gmail dot com> <CAHACq4qsJMXQAXnjEGp3xQjfyztVkhXccEeLYvz7Qn=piJD40Q at mail dot gmail dot com>
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 <firstname.lastname@example.org> 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.
> 2014-03-31 Cary Coutant <email@example.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.