From d3f3adbf40d52b6006be41dfaac77747609c696a Mon Sep 17 00:00:00 2001 From: Anton Lydike Date: Fri, 16 Jul 2021 19:54:08 +0200 Subject: [PATCH] using my own linker now --- Makefile | 2 +- kinclude/boot.S | 2 +- linker.ld | 31 +++++++++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 linker.ld diff --git a/Makefile b/Makefile index ee83dbf..adf7c3b 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ GCC_PREF=riscv32-unknown-elf- CC=$(GCC_PREF)gcc OBJDUMP=$(GCC_PREF)objdump CFLAGS=-I$(KLIBDIR) -march=rv32im -O3 -KERNEL_CFLAGS=-nostdlib +KERNEL_CFLAGS=-nostdlib -T linker.ld # dependencies that need to be built: _DEPS = ecall.c csr.c mutex.c sched.c diff --git a/kinclude/boot.S b/kinclude/boot.S index cfba7b8..96799e6 100644 --- a/kinclude/boot.S +++ b/kinclude/boot.S @@ -5,7 +5,7 @@ stack_bottom: stack_top: -.section .text +.section .text._start // Set up all the CSR mstatus_offsets diff --git a/linker.ld b/linker.ld new file mode 100644 index 0000000..2975ade --- /dev/null +++ b/linker.ld @@ -0,0 +1,31 @@ +OUTPUT_ARCH("riscv") +ENTRY(_start) +SECTIONS +{ + . = 0x00000100; + .text : + { + *(.text._start) + *(.text) + } + .sdata : + { + __global_pointer$ = . + 0x800; + *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata .srodata.*) + *(.sdata .sdata.* .gnu.linkonce.s.*) + } + _edata = .; PROVIDE (edata = .); + . = .; + __bss_start = .; + .sbss : + { + *(.dynsbss) + *(.sbss .sbss.* .gnu.linkonce.sb.*) + *(.scommon) + } + __bss_end = .; + .stack : + { + *(.stack) + } +} \ No newline at end of file