From dee154b35b001892ea81c1c640ad607ca817299f Mon Sep 17 00:00:00 2001 From: David Nadlinger Date: Thu, 24 Nov 2022 16:57:31 +0000 Subject: [PATCH] compiler: Add missing sections to kernel linker script This caused sporadic LoadFaults with LLD 14 and above, as they happened to lay out the (not otherwise mentioned) GOT/PLT such that they would overlap with the stack guard page. LLD does support the --orphan-handling=error option, which would be useful to avoid similar problems in the future, but then we'd need to mention all the other misc sections (symbol table, comments) in the linker script as well. GitHub: Fixes #1975. --- artiq/compiler/kernel.ld | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/artiq/compiler/kernel.ld b/artiq/compiler/kernel.ld index fafbea2af..bf080c37a 100644 --- a/artiq/compiler/kernel.ld +++ b/artiq/compiler/kernel.ld @@ -33,9 +33,19 @@ SECTIONS KEEP(*(.eh_frame_hdr)) } : text : eh_frame + .got : + { + *(.got) + } : text + + .got.plt : + { + *(.got.plt) + } : text + .data : { - *(.data) + *(.data .data.*) } : data .dynamic : @@ -51,6 +61,10 @@ SECTIONS _end = .; } + /* Kernel stack grows downward from end of memory, so put guard page after + * all the program contents. Note: This requires all loaded sections (at + * least those accessed) to be explicitly listed in the above! + */ . = ALIGN(0x1000); _sstack_guard = .; }