This is the mail archive of the
mailing list for the binutils project.
Re: Generating an ELF file with PT_NOTE before PT_LOAD
On Feb 21 2018, Mike Crowe <firstname.lastname@example.org> wrote:
> On Wednesday 21 February 2018 at 16:58:39 +0100, Andreas Schwab wrote:
>> On Feb 21 2018, Mike Crowe <email@example.com> wrote:
>> > --8<--
>> > #!/bin/sh
>> > set -e
>> > dd if=/dev/zero of=binary bs=1M count=1
>> > objcopy -I binary -O elf32-i386 -B i386 binary text.o
>> > gcc -c -m32 -x assembler - -o note.o <<EOF
>> > .section ".note.my-version", ""
>> I think you need to make that section allocated, otherwise the linker
>> will always place it after the other allocated sections.
> I think that I've done that by changing the last line you quoted to:
> .section ".note.my-version", "a"
> Now the script warns, but doesn't seem to do anything else differently.
> Here's the new output:
> ld.bfd: out.elf: warning: allocated section `.note' not in segment
Does it help to put the .note section also inside the load segment?
Andreas Schwab, SUSE Labs, firstname.lastname@example.org
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE 1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."