Skip to content

Commit 9208a60

Browse files
committed
soc: nxp: Fix boot header placement when using lld
As well described in a previous PR [1], the GNU ld and LLVM lld linkers treat the location counter (`.`) differently. lld always inteprets the location counter as an absolute address whereas ld interprets it as an offset from the start of the current object. The NXP boot header linker script files use `.` assignment to specify an offset within the rom_start region (ld-style). This causes lld to error out since it interprets this as the location counter moving backwards. To fix this, re-use the idea from the previous PR [1]: replace `. = FOO` with `. += FOO - (. - __rom_start_address)` This sets the location counter in a way that works with both ld and lld. [1] #58315 Signed-off-by: Kesavan Yogeswaran <[email protected]>
1 parent e02bd58 commit 9208a60

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

soc/nxp/imxrt/boot_header.ld

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ __Vectors = __VECTOR_TABLE;
1010
#endif
1111

1212
#if defined(CONFIG_BOOT_XSPI_NOR)
13-
. = CONFIG_XSPI_CONFIG_BLOCK_OFFSET;
13+
. += CONFIG_XSPI_CONFIG_BLOCK_OFFSET - (. - __rom_start_address);
1414
#else
15-
. = CONFIG_FLEXSPI_CONFIG_BLOCK_OFFSET;
15+
. += CONFIG_FLEXSPI_CONFIG_BLOCK_OFFSET - (. - __rom_start_address);
1616
#endif
1717
#if defined(CONFIG_SOC_SERIES_IMXRT11XX) || defined(CONFIG_SOC_SERIES_IMXRT10XX) || defined(CONFIG_SOC_SERIES_IMXRT118X)
1818
KEEP(*(.boot_hdr.conf))
@@ -22,13 +22,13 @@ KEEP(*(.flash_conf))
2222
#endif
2323
#if defined(CONFIG_SOC_SERIES_IMXRT118X)
2424
#ifdef CONFIG_EXTERNAL_MEM_CONFIG_DATA
25-
. = CONFIG_EXTERNAL_MEM_CONFIG_OFFSET;
25+
. += CONFIG_EXTERNAL_MEM_CONFIG_OFFSET - (. - __rom_start_address);
2626
KEEP(*(.boot_hdr.xmcd_data))
2727
#endif
28-
. = CONFIG_IMAGE_CONTAINER_OFFSET;
28+
. += CONFIG_IMAGE_CONTAINER_OFFSET - (. - __rom_start_address);
2929
KEEP(*(.boot_hdr.container))
3030
#else
31-
. = CONFIG_IMAGE_VECTOR_TABLE_OFFSET;
31+
. += CONFIG_IMAGE_VECTOR_TABLE_OFFSET - (. - __rom_start_address);
3232
KEEP(*(.boot_hdr.ivt))
3333
#endif
3434
#if defined(CONFIG_SOC_SERIES_IMXRT11XX) || defined(CONFIG_SOC_SERIES_IMXRT10XX)
@@ -37,7 +37,7 @@ KEEP(*(.boot_hdr.data))
3737
KEEP(*(.boot_hdr.dcd_data))
3838
#endif /* CONFIG_DEVICE_CONFIGURATION_DATA */
3939
#ifdef CONFIG_EXTERNAL_MEM_CONFIG_DATA
40-
. = CONFIG_EXTERNAL_MEM_CONFIG_OFFSET;
40+
. += CONFIG_EXTERNAL_MEM_CONFIG_OFFSET - (. - __rom_start_address);
4141
KEEP(*(.boot_hdr.xmcd_data))
4242
#endif
4343
#endif /* CONFIG_SOC_SERIES_IMXRT10XX || CONFIG_SOC_SERIES_IMXRT11XX */

soc/nxp/rw/boot_header.ld

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0
55
*/
66

7-
. = CONFIG_FLASH_CONFIG_OFFSET;
7+
. += CONFIG_FLASH_CONFIG_OFFSET - (. - __rom_start_address);
88
KEEP(*(.flash_conf))
9-
. = CONFIG_IMAGE_VECTOR_TABLE_OFFSET;
9+
. += CONFIG_IMAGE_VECTOR_TABLE_OFFSET - (. - __rom_start_address);
1010
KEEP(*(.boot_hdr.ivt))

0 commit comments

Comments
 (0)