From 3ecf192874ef98ca95e89649881fd996bee38340 Mon Sep 17 00:00:00 2001 From: conradgrobler <58467069+conradgrobler@users.noreply.github.com> Date: Wed, 20 Mar 2024 16:21:29 +0000 Subject: [PATCH] Add support for large sections to the Stage 0 linker script (#4920) The latest version of LLVM uses new sections when compiling with -C code-model=large (.ltext, .ldata, .lrodata and .lbss). This causes problems when building the Stage 0 binaries: the sections aren't referenced in the linker script so they get placed in locations that violate some of the requirements of the firmware layout. See https://lld.llvm.org/ELF/large_sections.html and b/330173039 for more context. This version is used by Rust nightly from version 1.78 onwards, so would block us from updating the Rust compiler without support for these. --- stage0_bin/layout.ld | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/stage0_bin/layout.ld b/stage0_bin/layout.ld index bb7f7f0ad32..5a250b2396d 100644 --- a/stage0_bin/layout.ld +++ b/stage0_bin/layout.ld @@ -86,14 +86,20 @@ SECTIONS { .bss (NOLOAD) : { bss_start = .; - *(.bss .bss.*) + /* Include large section (.lbss) to support large code model. + * See . + */ + *(.bss .bss.* .lbss.*) bss_size = . - bss_start; } > ram_low .data : AT ( ADDR (.text) + SIZEOF (.text) ) { data_start = .; - *(.data .data.*) + /* Include large section (.ldata) to support large code model. + * See . + */ + *(.data .data.* .ldata.*) data_size = . - data_start; } > ram_low @@ -118,11 +124,17 @@ SECTIONS { . = ORIGIN(bios); .rodata : { - KEEP(*(.rodata .rodata.*)) + /* Include large section (.lrodata) to support large code model. + * See . + */ + KEEP(*(.rodata .rodata.* .lrodata.*)) } > bios .text : { - *(.text .text.*) + /* Include large section (.ltext) to support large code model. + * See . + */ + *(.text .text.* .ltext.*) text_end = .; } > bios