gold's target->make_symbol()

Ian Lance Taylor iant@google.com
Thu Apr 17 07:28:00 GMT 2008


David Miller <davem@davemloft.net> writes:

> Gold has a target hook that seems to exist to facilitate the things
> that BFD elf backends use the BFD add symbol hook for.
>
> I need to use this to add proper support for STT_REGISTER symbols on
> sparc.
>
> But it's missing arguments :-) For example a reference to the symbol
> table entry isn't even provided.  I guess this was just never
> finished.

Right.

> There are two call sites for this target hook, one has a symtab
> reference available, the second does not.  But in the second case I
> don't think the hook is even needed as that function
> Symbol_table::define_special_symbol() probably does run for cases the
> target would care about.  Furthermore we would need to pass different
> args as a elfcpp::Sym to parse isn't available in this case.

What I was thinking at the time was that some targets might want to
record extra information for every Symbol, and this was a good hook
for them to do so.  But since Symbol is intentionally not a virtual
class, now I'm not sure this makes sense.

Maybe we should switch to a different approach.  When we see an ELF
symbol with a type between STT_LOOS and STT_HIPROC we should create an
ordinary Sized_symbol, and then call a target hook to initialize it.
Unfortunately this general approach will require target hooks for
every case where we make a decision based on the symbol's type.  I
can't think of a clean way to do this while keeping Symbol from having
a virtual table.

Ian



More information about the Binutils mailing list