From c485a9090a3b623a5de0c2e6da6c857770bf079a Mon Sep 17 00:00:00 2001 From: Ian McIntyre Date: Fri, 29 Sep 2023 14:48:23 -0400 Subject: Use an absolute address for __dcd LLVM's lld and GNU's ld have different ways of handling assignments in output sections. Unless we specify ABSOLUTE, ld treats the number '0' as a relative address from the section start, 0x6000_0000. On the other hand, lld treats '0' as if it were written with ABSOLUTE, and it ignores the ABSOLUTE function. So depending on your linker, __dcd would change values. This commit forces an absolute number for __dcd, ensuring a consistent value no matter the linker. --- src/host/imxrt-boot-header.x | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/host') diff --git a/src/host/imxrt-boot-header.x b/src/host/imxrt-boot-header.x index ed9d789..615fc65 100644 --- a/src/host/imxrt-boot-header.x +++ b/src/host/imxrt-boot-header.x @@ -71,7 +71,7 @@ SECTIONS __dcd_start = .; KEEP(*(.dcd)); /* Device Configuration Data */ __dcd_end = .; - __dcd = ((__dcd_end - __dcd_start) > 0) ? __dcd_start : 0; + __dcd = ((__dcd_end - __dcd_start) > 0) ? __dcd_start : ABSOLUTE(0); *(.Reset); /* Jam the imxrt-rt reset handler into flash. */ *(.__pre_init); /* Also jam the pre-init function, since we need it to run before instructions are placed. */ . = ORIGIN(FLASH) + 0x2000; /* Reserve the remaining 8K as a convenience for a non-XIP boot. */ -- cgit v1.2.3 From 96cea217ae8bb0464d7e5774d806435abd6ebb7f Mon Sep 17 00:00:00 2001 From: Ian McIntyre Date: Fri, 29 Sep 2023 16:16:43 -0400 Subject: Ensure __pre_init remains in binary GNU's LTO has a tendency to remove __pre_init, which is written in inline assembly. It doesn't realize that the reset handler references this symbol, because the reset handler is also written in inline assembly. Not sure why LLVM's linker doesn't also optimize it away, but this commit ensures that __pre_init remains in the output file. --- src/host/imxrt-link.x | 1 + 1 file changed, 1 insertion(+) (limited to 'src/host') diff --git a/src/host/imxrt-link.x b/src/host/imxrt-link.x index 71b697e..6c28f99 100644 --- a/src/host/imxrt-link.x +++ b/src/host/imxrt-link.x @@ -15,6 +15,7 @@ ENTRY(Reset); EXTERN(__EXCEPTIONS); /* depends on all the these PROVIDED symbols */ EXTERN(DefaultHandler); +EXTERN(__pre_init); PROVIDE(NonMaskableInt = DefaultHandler); EXTERN(HardFaultTrampoline); -- cgit v1.2.3