Creating arbitrary dynamic tags with BFD ld

Florian Weimer fweimer@redhat.com
Tue Oct 15 11:51:00 GMT 2019


* Alan Modra:

> On Mon, Sep 30, 2019 at 02:04:35PM +0200, Florian Weimer wrote:
>> Can BFD ld create arbitrary dynamic tags (with purely numeric arguments)
>> even if it knows nothing about them?
>
> Yes, if you are willing to edit linker scripts.
> Inserting *special_dyn.o(.data) into the normal .dynamic like this:
>   .dynamic        : { *special_dyn.o(.dynamic) *(.dynamic) }
> will place whatever you put in special_dyn.o .dynamic section at the
> start of .dynamic.  Here's an example special_dyn.s.
>  .section .dynamic,"a",%6
>  .dc.a 0x7ffffffe
>  .dc.a 0x12345678

Very interesting.  Out of curiosity, is there something similar for
program header tags?

> You can't put your extra tags at the end of the usual ld supplied ones
> because ld will always add at least one DT_NULL which usually
> terminates the section.

Ahh.  Well, we could continue parsing because we control the
implementation and have the segment size, but that it is probably too
hackish.

It's curious that for .dynamic, ld provides termination, but not for
.eh_frame.

Thanks,
Florian



More information about the Binutils mailing list