Skip to content

Commit cd5acae

Browse files
committed
Sort .text section to reduce fill
1 parent ec067ae commit cd5acae

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

ports/atmel-samd/boards/common.template.ld

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,12 @@ SECTIONS
2727
. = ALIGN(4);
2828
_sfixed = .;
2929
KEEP(*(.vectors)) /* isr vector table */
30-
*(.text) /* .text sections (code) */
31-
*(.text*) /* .text* sections (code) */
30+
31+
/* Sort text sections so that they have fewer *fill* bytes needed. */
32+
*SORT_BY_ALIGNMENT(SORT_BY_NAME(.text)) /* .text sections (code) */
33+
*SORT_BY_ALIGNMENT(SORT_BY_NAME(.text*)) /* .text* sections (code) */
34+
35+
/* Don't sort rodata because it impacts codegen size. */
3236
*(.rodata) /* .rodata sections (constants, strings, etc.) */
3337
*(.rodata*) /* .rodata* sections (constants, strings, etc.) */
3438

@@ -62,8 +66,8 @@ SECTIONS
6266
_srelocate = .; /* create a global symbol at data start; used by startup code in order to initialize the .data section in RAM */
6367
*(.ramfunc)
6468
*(.ramfunc*)
65-
*(.data) /* .data sections */
66-
*(.data*) /* .data* sections */
69+
*SORT_BY_ALIGNMENT(SORT_BY_NAME(.data)) /* .data sections */
70+
*SORT_BY_ALIGNMENT(SORT_BY_NAME(.data*)) /* .data* sections */
6771

6872
. = ALIGN(4);
6973
_erelocate = .; /* define a global symbol at data end; used by startup code in order to initialize the .data section in RAM */
@@ -76,7 +80,7 @@ SECTIONS
7680
_sbss = .;
7781
_szero = .; /* define a global symbol at bss start; used by startup code */
7882
*(.bss)
79-
*(.bss*)
83+
*SORT_BY_ALIGNMENT(SORT_BY_NAME(.bss*))
8084
*(COMMON)
8185

8286
. = ALIGN(4);

0 commit comments

Comments
 (0)