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: [PATCH] Add plugin interface to LD [6/4] Add archive support to plugin interface.


On 09/26/2010 05:43 PM, Dave Korn wrote:
>   This one isn't as neat as the other patches.  I couldn't see any way to use
> the existing functionality of the linker "add_archive_element" callback to
> supply an alternative BFD with its own set of symbols from the IR, so I had to
> extend BFD to make this possible.  And I didn't want to change the interface
> of add_archive_element, since it's one of the few actual public interfaces of
> libbfd, and we don't have any versioning.

Nothing in libbfd pretends to have a stable ABI, so I don't think you
need to worry about that.

>   So that led me to take a somewhat ugly solution: I added a new member to
> struct areltdata, and use that to communicate between libbfd and the linker
> callback.  The member gets zeroed immediately before calling the callback, and
> if on return it has been set to point to a BFD, the symbols from that BFD are
> added to the linker hash table instead of the archive element's own symbols.
> It's not ideal, but I think it's OK enough; there are only so many places from
> which BFD calls the hook.  If anyone has a better idea how to implement this,
> I'm all ears.  Otherwise, OK?

I think I'd prefer a fourth argument for add_archive_element which, if 
non-null, receives the replacement.  Thus for a.out we can simply not
change anything except add the NULL 4th argument.  (Recall that a.out
cannot represent LTO data at all, and so needn't worry about this whole
plugin business.)

Honestly, I think it would clean up some of your arelt_substitute_bfd
checks as well.

> +#ifdef ENABLE_PLUGINS
> +  lang_input_statement_type orig_input;
> +  int fildes;
> +#endif /* ENABLE_PLUGINS */

See previous comments re keeping decls near code.

> +    info_msg ("%I\n",
> +#ifdef ENABLE_PLUGINS
> +	&orig_input
> +#else
> +	input
> +#endif /* ENABLE_PLUGINS */

In this case I don't think you need to conditionalize orig_input.
Just do it all the time and be done with it.


r~


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