ld, makefiles: use ld.lld

pull/1745/head
occheung 2021-08-17 11:42:04 +08:00
parent fc42d053d9
commit 1293e0750e
6 changed files with 39 additions and 26 deletions

View File

@ -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
}

View File

@ -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.*)

View File

@ -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

View File

@ -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

View File

@ -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);

View File

@ -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
}