Skip to content

Commit 68dbad6

Browse files
committed
ld: Reset linker '.' value after .ER_CODE_SRAM section
The linker appears to get confused by this section which is relocated to CODE_RAM but loaded to FLASH. Clear things up by forcing the '.' value back to the correct FLASH address which will then be used by subsequent sections. Signed-off-by: Keith Packard <[email protected]>
1 parent cc80026 commit 68dbad6

File tree

6 files changed

+20
-0
lines changed

6 files changed

+20
-0
lines changed

platform/ext/common/gcc/tfm_common_s.ld.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ SECTIONS
192192
. = ALIGN(4); /* This alignment is needed to make the section size 4 bytes aligned */
193193
} > CODE_RAM AT > FLASH
194194

195+
/* Reset current position for subsequent sections */
196+
. = LOADADDR(.ER_CODE_SRAM) + SIZEOF(.ER_CODE_SRAM);
197+
195198
ASSERT(S_RAM_CODE_START % 4 == 0, "S_RAM_CODE_START must be divisible by 4")
196199

197200
Image$$ER_CODE_SRAM$$RO$$Base = ADDR(.ER_CODE_SRAM);

platform/ext/common/gcc/tfm_isolation_s.ld.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,9 @@ SECTIONS
327327
. = ALIGN(4); /* This alignment is needed to make the section size 4 bytes aligned */
328328
} > CODE_RAM AT > FLASH
329329

330+
/* Reset current position for subsequent sections */
331+
. = LOADADDR(.ER_CODE_SRAM) + SIZEOF(.ER_CODE_SRAM);
332+
330333
ASSERT(S_RAM_CODE_START % 4 == 0, "S_RAM_CODE_START must be divisible by 4")
331334

332335
Image$$ER_CODE_SRAM$$RO$$Base = ADDR(.ER_CODE_SRAM);

platform/ext/common/llvm/tfm_isolation_s.ld.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ SECTIONS
303303
. = ALIGN(4); /* This alignment is needed to make the section size 4 bytes aligned */
304304
} > CODE_RAM AT > FLASH
305305

306+
/* Reset current position for subsequent sections */
307+
. = LOADADDR(.ER_CODE_SRAM) + SIZEOF(.ER_CODE_SRAM);
308+
306309
ASSERT(S_RAM_CODE_START % 4 == 0, "S_RAM_CODE_START must be divisible by 4")
307310

308311
Image$$ER_CODE_SRAM$$RO$$Base = ADDR(.ER_CODE_SRAM);

platform/ext/target/arm/musca_b1/Device/Source/gcc/musca_bl2.ld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ SECTIONS
5858
*libflash_drivers.o(.rodata*)
5959
. = ALIGN(4); /* This alignment is needed to make the section size 4 bytes aligned */
6060
} > CODE_RAM AT > FLASH
61+
62+
/* Reset current position for subsequent sections */
63+
. = LOADADDR(.ER_CODE_SRAM) + SIZEOF(.ER_CODE_SRAM);
64+
6165
Image$$ER_CODE_SRAM$$Base = ADDR(.ER_CODE_SRAM);
6266
Image$$ER_CODE_SRAM$$Limit = ADDR(.ER_CODE_SRAM) + SIZEOF(.ER_CODE_SRAM);
6367

platform/ext/target/arm/musca_b1/Device/Source/llvm/musca_bl2.ld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ SECTIONS
5757
*libflash_drivers.o(.rodata*)
5858
. = ALIGN(4); /* This alignment is needed to make the section size 4 bytes aligned */
5959
} > CODE_RAM AT > FLASH
60+
61+
/* Reset current position for subsequent sections */
62+
. = LOADADDR(.ER_CODE_SRAM) + SIZEOF(.ER_CODE_SRAM);
63+
6064
Image$$ER_CODE_SRAM$$Base = ADDR(.ER_CODE_SRAM);
6165
Image$$ER_CODE_SRAM$$Limit = ADDR(.ER_CODE_SRAM) + SIZEOF(.ER_CODE_SRAM);
6266

platform/ext/target/rpi/rp2350/linker_s.ld

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ SECTIONS
150150
. = ALIGN(4); /* This alignment is needed to make the section size 4 bytes aligned */
151151
} > CODE_RAM AT > FLASH
152152

153+
/* Reset current position for subsequent sections */
154+
. = LOADADDR(.ER_CODE_SRAM) + SIZEOF(.ER_CODE_SRAM);
155+
153156
ASSERT(S_RAM_CODE_START % 4 == 0, "S_RAM_CODE_START must be divisible by 4")
154157

155158
Image$$ER_CODE_SRAM$$RO$$Base = ADDR(.ER_CODE_SRAM);

0 commit comments

Comments
 (0)