From 40c491741476323b40f04650348dd499059b64bd Mon Sep 17 00:00:00 2001 From: Alexander von Gluck IV Date: Wed, 19 Feb 2020 18:41:59 -0600 Subject: [PATCH] riscv64: Add missing linker scripts, fix some kernel dependencies Change-Id: Ic63b0bbdddda629bb9bc76017a806746c983023e --- src/system/boot/arch/riscv64/Jamfile | 47 ++++++++++---- src/system/kernel/lib/arch/riscv64/Jamfile | 2 +- .../ldscripts/riscv64/runtime_loader.ld | 63 +++++++++++++++++++ src/system/libroot/os/arch/riscv64/Jamfile | 1 + 4 files changed, 100 insertions(+), 13 deletions(-) create mode 100644 src/system/ldscripts/riscv64/runtime_loader.ld diff --git a/src/system/boot/arch/riscv64/Jamfile b/src/system/boot/arch/riscv64/Jamfile index e309eb55a8..1d074a78d8 100644 --- a/src/system/boot/arch/riscv64/Jamfile +++ b/src/system/boot/arch/riscv64/Jamfile @@ -15,19 +15,42 @@ local kernelLibArchObjects = memset.o ; -BootMergeObject boot_arch_$(TARGET_KERNEL_ARCH).o : - debug_uart_8250.cpp - #arch_uart_8250.cpp - arch_elf.cpp - : # additional flags - : - $(kernelArchObjects) - $(kernelLibArchObjects) +local kernelDebugSources = + blue_screen.cpp + frame_buffer_console.cpp ; -SEARCH on [ FGristFiles arch_elf.cpp arch_uart_8250.cpp ] - = [ FDirName $(HAIKU_TOP) src system kernel arch $(TARGET_KERNEL_ARCH) ] ; +local kernelArchDriverSources = + arch_elf.cpp + # Serial UART Drivers + #arch_uart_8250.cpp + #arch_uart_8250_omap.cpp + #arch_uart_pl011.cpp +; -SEARCH on [ FGristFiles debug_uart_8250.cpp ] - = [ FDirName $(HAIKU_TOP) src system kernel arch generic ] ; +local kernelGenericDriverSources = + debug_uart_8250.cpp +; +local platform ; +for platform in [ MultiBootSubDirSetup u-boot efi ] { + on $(platform) { + DEFINES += _BOOT_MODE ; + BootMergeObject [ FGristFiles boot_arch_$(TARGET_KERNEL_ARCH).o ] : + $(kernelDebugSources) + $(kernelArchDriverSources) + $(kernelGenericDriverSources) + : # additional flags + : + $(kernelArchObjects) + $(kernelLibArchObjects) + ; + + SEARCH on [ FGristFiles $(kernelArchDriverSources) ] + = [ FDirName $(HAIKU_TOP) src system kernel arch $(TARGET_KERNEL_ARCH) ] ; + SEARCH on [ FGristFiles $(kernelGenericDriverSources) ] + = [ FDirName $(HAIKU_TOP) src system kernel arch generic ] ; + SEARCH on [ FGristFiles $(kernelDebugSources) ] + = [ FDirName $(HAIKU_TOP) src system kernel debug ] ; + } +} diff --git a/src/system/kernel/lib/arch/riscv64/Jamfile b/src/system/kernel/lib/arch/riscv64/Jamfile index bf5138168a..7b143796e6 100644 --- a/src/system/kernel/lib/arch/riscv64/Jamfile +++ b/src/system/kernel/lib/arch/riscv64/Jamfile @@ -9,7 +9,7 @@ SEARCH_SOURCE += [ FDirName $(librootSources) os arch $(TARGET_ARCH) ] ; SEARCH_SOURCE += [ FDirName $(librootSources) os arch generic ] ; KernelMergeObject kernel_os_arch_$(TARGET_ARCH).o : - #byteorder.S + byteorder.S generic_atomic.cpp generic_system_time_nsecs.cpp diff --git a/src/system/ldscripts/riscv64/runtime_loader.ld b/src/system/ldscripts/riscv64/runtime_loader.ld new file mode 100644 index 0000000000..1f5b386262 --- /dev/null +++ b/src/system/ldscripts/riscv64/runtime_loader.ld @@ -0,0 +1,63 @@ +OUTPUT_FORMAT("elf64-littleriscv", "elf64-littleriscv", "elf64-littleriscv") +OUTPUT_ARCH(riscv) + +ENTRY(runtime_loader) +SEARCH_DIR("libgcc"); +SECTIONS +{ + . = 0x00100000 + SIZEOF_HEADERS; + + .interp : { *(.interp) } + .hash : { *(.hash) } + .dynsym : { *(.dynsym) } + .dynstr : { *(.dynstr) } + .rel.text : { *(.rel.text) *(.rel.gnu.linkonce.t*) } + .rela.text : { *(.rela.text) *(.rela.gnu.linkonce.t*) } + .rel.data : { *(.rel.data) *(.rel.gnu.linkonce.d*) } + .rela.data : { *(.rela.data) *(.rela.gnu.linkonce.d*) } + .rel.rodata : { *(.rel.rodata) *(.rel.gnu.linkonce.r*) } + .rela.rodata : { *(.rela.rodata) *(.rela.gnu.linkonce.r*) } + .rel.got : { *(.rel.got) } + .rela.got : { *(.rela.got) } + .rel.ctors : { *(.rel.ctors) } + .rela.ctors : { *(.rela.ctors) } + .rel.dtors : { *(.rel.dtors) } + .rela.dtors : { *(.rela.dtors) } + .rel.init : { *(.rel.init) } + .rela.init : { *(.rela.init) } + .rel.fini : { *(.rel.fini) } + .rela.fini : { *(.rela.fini) } + .rel.bss : { *(.rel.bss) } + .rela.bss : { *(.rela.bss) } + .rel.plt : { *(.rel.plt) } + .rela.plt : { *(.rela.plt) } + .init : { *(.init) } =0x9090 + .plt : { *(.plt) } + + /* text/read-only data */ + .text : { *(.text .gnu.linkonce.t.*) } + + .rodata : { *(.rodata) } + + /* writable data */ + . = ALIGN(0x1000) + (. & (0x1000 - 1)); + __data_start = .; + PROVIDE(_data_start = .); + .data : { *(.data .gnu.linkonce.d.*) } + + __ctor_list = .; + PROVIDE (_ctor_list = .); + .ctors : { *(.ctors) } + PROVIDE (__ctor_end = .); + + + /* uninitialized data (in same segment as writable data) */ + PROVIDE (__bss_start = .); + .bss : { *(.bss) } + + . = ALIGN(0x1000); + PROVIDE (_end = .); + + /* Strip unnecessary stuff */ + /DISCARD/ : { *(.comment .note .dtors) } +} diff --git a/src/system/libroot/os/arch/riscv64/Jamfile b/src/system/libroot/os/arch/riscv64/Jamfile index e16a245868..c12c9c6c41 100644 --- a/src/system/libroot/os/arch/riscv64/Jamfile +++ b/src/system/libroot/os/arch/riscv64/Jamfile @@ -23,6 +23,7 @@ for architectureObject in [ MultiArchSubDirSetup riscv64 ] { thread.c generic_atomic.cpp + generic_stack_trace.cpp generic_system_time_nsecs.cpp ; }