Skip to content
This repository was archived by the owner on Jan 24, 2022. It is now read-only.

Commit ac06446

Browse files
committed
Fix INSERT AFTER for .text and .bss
Additionally include COMMON symbols (uninitialized statics from C) in bss.
1 parent 2c56bfd commit ac06446

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

link.x.in

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,10 @@ SECTIONS
8888
*(.text .text.*);
8989
*(.HardFaultTrampoline);
9090
*(.HardFault.*);
91-
. = ALIGN(4);
92-
__etext = .;
91+
. = ALIGN(4); /* 4-byte align the end (VMA) of this section */
9392
} > FLASH
93+
. = ALIGN(4); /* Ensure __etext is aligned if something unaligned is inserted after .text */
94+
__etext = .; /* Define outside of .text to allow using INSERT AFTER .text */
9495

9596
/* ### .rodata */
9697
.rodata __etext : ALIGN(4)
@@ -119,14 +120,16 @@ SECTIONS
119120
__sidata = LOADADDR(.data);
120121

121122
/* ### .bss */
123+
. = ALIGN(4);
124+
__sbss = .; /* Define outside of section to include INSERT BEFORE/AFTER symbols */
122125
.bss (NOLOAD) : ALIGN(4)
123126
{
124-
. = ALIGN(4);
125-
__sbss = .;
126127
*(.bss .bss.*);
128+
*(COMMON); /* Uninitialized C statics */
127129
. = ALIGN(4); /* 4-byte align the end (VMA) of this section */
128-
__ebss = .;
129130
} > RAM
131+
. = ALIGN(4); /* Ensure __ebss is aligned if something unaligned is inserted after .bss */
132+
__ebss = .;
130133

131134
/* ### .uninit */
132135
.uninit (NOLOAD) : ALIGN(4)

0 commit comments

Comments
 (0)