Skip to content

Commit 0c2a7d5

Browse files
committed
Re-arrange flash layout to make linker happy
Splitting data landing in flash resulted in the linker getting upset in a couple of ways. First, the constructor/destructor arrays were no longer getting aligned via the ALIGN statement above them, resulting in the symbols being mis-aligned from the actual arrays. Second, the constructors and destructors were somehow getting marked 'writable' which made the linker unhappy as that meant the contents of flash were marked both executable and writable. Fix this up by stuffing the constructor/destructor arrays into the .text segment along with the ALIGN statement. Signed-off-by: Keith Packard <[email protected]>
1 parent 1cc0a47 commit 0c2a7d5

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

picolibc.ld.in

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,23 +75,6 @@ SECTIONS
7575
PROVIDE (@PREFIX@__etext = @PREFIX@__text_end);
7676
PROVIDE (@PREFIX@_etext = @PREFIX@__text_end);
7777
PROVIDE (@PREFIX@etext = @PREFIX@__text_end);
78-
} >flash AT>flash :text
79-
80-
.rodata : {
81-
/* read-only data */
82-
*(.rdata)
83-
*(.rodata .rodata.*)
84-
*(.gnu.linkonce.r.*)
85-
86-
*(.srodata.cst16)
87-
*(.srodata.cst8)
88-
*(.srodata.cst4)
89-
*(.srodata.cst2)
90-
*(.srodata .srodata.*)
91-
} >flash AT>flash :text
92-
93-
.data.rel.ro : {
94-
*(.data.rel.ro .data.rel.ro.*)
9578

9679
/* Need to pre-align so that the symbols come after padding */
9780
. = ALIGN(@DEFAULT_ALIGNMENT@);
@@ -113,6 +96,28 @@ SECTIONS
11396

11497
} >flash AT>flash :text
11598

99+
.rodata : {
100+
101+
/* read-only data */
102+
*(.rdata)
103+
*(.rodata .rodata.*)
104+
*(.gnu.linkonce.r.*)
105+
106+
*(.srodata.cst16)
107+
*(.srodata.cst8)
108+
*(.srodata.cst4)
109+
*(.srodata.cst2)
110+
*(.srodata .srodata.*)
111+
112+
} >flash AT>flash :text
113+
114+
.data.rel.ro : {
115+
116+
/* data that needs relocating */
117+
*(.data.rel.ro .data.rel.ro.*)
118+
119+
} >flash AT>flash :text
120+
116121
/*
117122
* Needs to be in its own segment with the PLT entries first
118123
* so that the linker will compute the offsets to those

0 commit comments

Comments
 (0)