From 1293e0750e6769b66a712c47275a3bd2a707125d Mon Sep 17 00:00:00 2001 From: occheung Date: Tue, 17 Aug 2021 11:42:04 +0800 Subject: [PATCH] ld, makefiles: use ld.lld --- artiq/firmware/bootloader/bootloader.ld | 20 +++++++++---------- artiq/firmware/ksupport/ksupport.ld | 8 ++++---- .../libboard_misoc/riscv32imac/vectors.S | 1 - artiq/firmware/runtime/Makefile | 4 ++-- artiq/firmware/runtime/runtime.ld | 14 ++++++++----- artiq/firmware/satman/satman.ld | 18 ++++++++++++++--- 6 files changed, 39 insertions(+), 26 deletions(-) diff --git a/artiq/firmware/bootloader/bootloader.ld b/artiq/firmware/bootloader/bootloader.ld index b52abe930..3837f3408 100644 --- a/artiq/firmware/bootloader/bootloader.ld +++ b/artiq/firmware/bootloader/bootloader.ld @@ -15,12 +15,10 @@ SECTIONS *(.text .text.*) } > rom - /* - * The compiler_builtins crate includes some GOTPC relocations, which require a GOT symbol, - * but don't actually need a GOT. This really ought to be fixed on rustc level, but I'm afraid - * it will add further complications to our build system that aren't pulling their weight. - */ - _GLOBAL_OFFSET_TABLE_ = .; + .eh_frame : + { + *(.eh_frame.*) + } > rom .rodata : { @@ -29,13 +27,13 @@ SECTIONS _end = .; } > rom - .crc ALIGN(4) : + .crc (NOLOAD) : ALIGN(4) { _crc = .; . += 4; - } + } > rom - .bss : + .bss (NOLOAD) : { _fbss = .; *(.sbss .sbss.* .bss .bss.*); @@ -43,11 +41,11 @@ SECTIONS _ebss = .; } > sram - .stack : + .stack (NOLOAD) : ALIGN(16) { /* Ensure we have a certain amount of space available for stack. */ /*. = ORIGIN(sram) + LENGTH(sram) - 0x1a00; */ - . = ORIGIN(sram) + LENGTH(sram) - 4; + . = ORIGIN(sram) + LENGTH(sram) - 16; _fstack = .; } > sram } diff --git a/artiq/firmware/ksupport/ksupport.ld b/artiq/firmware/ksupport/ksupport.ld index b139833f3..62fbd3518 100644 --- a/artiq/firmware/ksupport/ksupport.ld +++ b/artiq/firmware/ksupport/ksupport.ld @@ -15,7 +15,7 @@ MEMORY { } /* Kernel stack is at the end of main RAM. */ -_fstack = ORIGIN(main_ram) + LENGTH(main_ram) - 4; +_fstack = ORIGIN(main_ram) + LENGTH(main_ram) - 16; /* Force ld to make the ELF header as loadable. */ PHDRS @@ -53,19 +53,19 @@ SECTIONS .eh_frame : { KEEP(*(.eh_frame)) - } :text + } > ksupport :text .eh_frame_hdr : { KEEP(*(.eh_frame_hdr)) - } :text :eh_frame + } > ksupport :text :eh_frame .data : { *(.data .data.*) } - .bss : + .bss (NOLOAD) : { _fbss = .; *(.bss .bss.*) diff --git a/artiq/firmware/libboard_misoc/riscv32imac/vectors.S b/artiq/firmware/libboard_misoc/riscv32imac/vectors.S index a571a4903..19b6c5c3f 100644 --- a/artiq/firmware/libboard_misoc/riscv32imac/vectors.S +++ b/artiq/firmware/libboard_misoc/riscv32imac/vectors.S @@ -128,7 +128,6 @@ _abs_start: Saves caller saved registers ra, t0..6, a0..7, calls exception, restores caller saved registers and then returns. */ -.section .trap, "ax" .global _start_trap /* Make it .weak so PAC/HAL can provide their own if needed. */ .weak _start_trap diff --git a/artiq/firmware/runtime/Makefile b/artiq/firmware/runtime/Makefile index 2b98acc43..766804e68 100644 --- a/artiq/firmware/runtime/Makefile +++ b/artiq/firmware/runtime/Makefile @@ -18,10 +18,10 @@ $(RUSTOUT)/libruntime.a: runtime.elf: $(RUSTOUT)/libruntime.a ksupport_data.o $(link) -T $(RUNTIME_DIRECTORY)/runtime.ld \ - -lunwind-bare + -lunwind-bare -m elf32lriscv ksupport_data.o: ../ksupport/ksupport.elf - $(LD) -m elf32lriscv -b binary -o $@ $< + $(LD) -r -m elf32lriscv -b binary -o $@ $< %.bin: %.elf $(objcopy) -O binary diff --git a/artiq/firmware/runtime/runtime.ld b/artiq/firmware/runtime/runtime.ld index c93a5e4b1..57d76ee45 100644 --- a/artiq/firmware/runtime/runtime.ld +++ b/artiq/firmware/runtime/runtime.ld @@ -36,10 +36,14 @@ SECTIONS __eh_frame_hdr_start = SIZEOF(.eh_frame_hdr) > 0 ? ADDR(.eh_frame_hdr) : 0; __eh_frame_hdr_end = SIZEOF(.eh_frame_hdr) > 0 ? . : 0; + .gcc_except_table : + { + *(.gcc_except_table) + } > runtime + /* https://sourceware.org/bugzilla/show_bug.cgi?id=20475 */ .got : { - _GLOBAL_OFFSET_TABLE_ = .; *(.got) } > runtime @@ -58,20 +62,20 @@ SECTIONS *(.data .data.*) } > runtime - .bss ALIGN(4) : + .bss (NOLOAD) : ALIGN(4) { _fbss = .; *(.sbss .sbss.* .bss .bss.*); _ebss = .; } > runtime - .stack : + .stack (NOLOAD) : ALIGN(16) { . += 0x4000; - _fstack = . - 4; + _fstack = . - 16; } > runtime - .heap : + .heap (NOLOAD) : { _fheap = .; . = ORIGIN(runtime) + LENGTH(runtime); diff --git a/artiq/firmware/satman/satman.ld b/artiq/firmware/satman/satman.ld index 927af6022..bf7ef51d0 100644 --- a/artiq/firmware/satman/satman.ld +++ b/artiq/firmware/satman/satman.ld @@ -14,6 +14,13 @@ SECTIONS *(.text .text.*) } > main_ram + .eh_frame : + { + __eh_frame_start = .; + KEEP(*(.eh_frame)) + __eh_frame_end = .; + } > main_ram + /* https://sourceware.org/bugzilla/show_bug.cgi?id=20475 */ .got : { @@ -38,7 +45,12 @@ SECTIONS *(.data .data.*) } > main_ram - .bss ALIGN(4) : + .sdata : + { + *(.sdata .sdata.*) + } > main_ram + + .bss (NOLOAD) : ALIGN(4) { _fbss = .; *(.sbss .sbss.* .bss .bss.*); @@ -46,10 +58,10 @@ SECTIONS _ebss = .; } > main_ram - .stack : + .stack (NOLOAD) : ALIGN(16) { _estack = .; . += 0x10000; - _fstack = . - 4; + _fstack = . - 16; } > main_ram }