This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Creating arbitrary dynamic tags with BFD ld
- From: Florian Weimer <fweimer at redhat dot com>
- To: Alan Modra <amodra at gmail dot com>
- Cc: binutils at sourceware dot org
- Date: Tue, 15 Oct 2019 13:51:42 +0200
- Subject: Re: Creating arbitrary dynamic tags with BFD ld
- References: <87blv23s8c.fsf@oldenburg2.str.redhat.com> <20190930135936.GC20197@bubble.grove.modra.org>
* 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