Great write up, just what I was looking for in an upcoming project that I am setting up!
I noticed that for my project, even though I added the .gnu_build_id
section after the .text
section in the linker script, I was seeing that build-id was being allocated at 0x0.
Sections:
Idx Name Size VMA LMA File off Algn
0 .note.gnu.build-id 00000024 00000000 00000000 00010000 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
1 .text 0000cec4 00000030 00000030 00010030 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
2 .data 0000012c 20000000 0000cef4 00020000 2**2
CONTENTS, ALLOC, LOAD, DATA
3 .bss 000037c5 2000012c 0000d020 0002012c 2**2
ALLOC
I had to add KEEP(*(.note.gnu.build-id))
before PROVIDE(g_note_build_id = .);
. So my final linker section looked like this.
.gnu_build_id :
{
KEEP(*(.note.gnu.build-id))
PROVIDE(g_note_build_id = .);
*(.note.gnu_build_id)
_etext = .;
} > FLASH
Once I did this, my allocation was as expected.
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 0000cec4 00000000 00000000 00010000 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE
1 .gnu_build_id 00000024 0000cec4 0000cec4 0001cec4 2**2
CONTENTS, ALLOC, LOAD, READONLY, DATA
2 .data 0000012c 20000000 0000cee8 00020000 2**2
CONTENTS, ALLOC, LOAD, DATA`
Hope this helps others.
Software Versions:
arm-none-eabi-gcc (GNU Tools for Arm Embedded Processors 9-2019-q4-major) 9.2.1 20191025
(release) [ARM/arm-9-branch revision 277599]
GNU ld (GNU Tools for Arm Embedded Processors 9-2019-q4-major) 2.33.1.20191025
Copyright (C) 2019 Free Software Foundation, Inc.