Skip to content

Commit

Permalink
Add support for large sections to the Stage 0 linker script (#4920)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
conradgrobler authored Mar 20, 2024
1 parent db28d2e commit 3ecf192
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions stage0_bin/layout.ld
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,20 @@ SECTIONS {

.bss (NOLOAD) : {
bss_start = .;
*(.bss .bss.*)
/* Include large section (.lbss) to support large code model.
* See <https://lld.llvm.org/ELF/large_sections.html>.
*/
*(.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 <https://lld.llvm.org/ELF/large_sections.html>.
*/
*(.data .data.* .ldata.*)
data_size = . - data_start;
} > ram_low

Expand All @@ -118,11 +124,17 @@ SECTIONS {
. = ORIGIN(bios);

.rodata : {
KEEP(*(.rodata .rodata.*))
/* Include large section (.lrodata) to support large code model.
* See <https://lld.llvm.org/ELF/large_sections.html>.
*/
KEEP(*(.rodata .rodata.* .lrodata.*))
} > bios

.text : {
*(.text .text.*)
/* Include large section (.ltext) to support large code model.
* See <https://lld.llvm.org/ELF/large_sections.html>.
*/
*(.text .text.* .ltext.*)
text_end = .;
} > bios

Expand Down

0 comments on commit 3ecf192

Please sign in to comment.