arm: kernel link cleanup and fixes

* Removes several previous hacks, and makes kernel loading
  by our bootloader more reliable.
* Long list of "Couldn't find both text and data" errors
  no gone in our bootloader as it loads our kernel

Change-Id: Ic9f5ed44975d41fb22d7ab19536261432abe84ba
Reviewed-on: https://review.haiku-os.org/c/haiku/+/3444
Reviewed-by: Alex von Gluck IV <kallisti5@unixzen.com>
Reviewed-by: Fredrik Holmqvist <fredrik.holmqvist@gmail.com>
Reviewed-by: Adrien Destugues <pulkomandy@gmail.com>
This commit is contained in:
Fredrik Holmqvist 2020-11-30 12:42:29 -06:00 committed by Alex von Gluck IV
parent 64fc5a66b1
commit cb26d04e81
3 changed files with 33 additions and 52 deletions

View File

@ -401,21 +401,14 @@ rule KernelArchitectureSetup architecture
switch $(cpu) {
case arm :
# Workaround for ld using 32k for alignment despite forcing it in the config...
# should definitely not be needed!
HAIKU_KERNEL_LINKFLAGS +=
-Wl,-z -Wl,max-page-size=0x1000
-Wl,-z -Wl,common-page-size=0x1000 ;
HAIKU_KERNEL_PIC_LINKFLAGS += -z max-page-size=0x1000 ;
HAIKU_KERNEL_ADDON_LINKFLAGS += -z max-page-size=0x1000 ;
HAIKU_KERNEL_PIC_CCFLAGS = -fno-pic ;
case arm64 :
# Workaround for ld using 32k for alignment despite forcing it in the config...
# should definitely not be needed!
HAIKU_KERNEL_LINKFLAGS +=
-Wl,-z -Wl,max-page-size=0x1000
-Wl,-z -Wl,common-page-size=0x1000 ;
HAIKU_KERNEL_PIC_CCFLAGS = -fPIC ;
HAIKU_KERNEL_PIC_LINKFLAGS = -shared -fPIC ;
HAIKU_KERNEL_PIC_LINKFLAGS += -z max-page-size=0x1000 ;
HAIKU_KERNEL_ADDON_LINKFLAGS += -z max-page-size=0x1000 ;
HAIKU_KERNEL_PIC_CCFLAGS = -fno-pic ;
case ppc :
# Build a position independent PPC kernel. We need to be able to

View File

@ -8,14 +8,20 @@ UsePrivateHeaders [ FDirName kernel boot platform efi ] ;
local platform ;
for platform in [ MultiBootSubDirSetup efi ] {
on $(platform) {
{
local defines = _BOOT_MODE _BOOT_PLATFORM_EFI ;
defines = [ FDefines $(defines) ] ;
SubDirCcFlags $(defines) ;
SubDirC++Flags $(defines) -fno-rtti ;
}
local arch_src =
crt0-efi-$(TARGET_ARCH).S
entry.S
relocation_func.cpp
arch_mmu.cpp
arch_smp.cpp
arch_start.cpp
arch_mmu.cpp
arch_timer.cpp
;

View File

@ -1,64 +1,46 @@
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
OUTPUT_ARCH(arm)
/* XXX: this shouldn't be needed to make kernel_arm have separate text and data segments!!! */
PHDRS
{
headers PT_PHDR PHDRS ;
text PT_LOAD FILEHDR PHDRS ;
data PT_LOAD ;
dynamic PT_DYNAMIC ;
}
ENTRY(_start)
SEARCH_DIR("libgcc");
SECTIONS
{
. = 0x80000000 + SIZEOF_HEADERS;
.interp : { *(.interp) } :text
.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.text : { *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*) }
.rela.data : { *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*) }
.rela.rodata : { *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*) }
.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.bss : { *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*) }
.rela.plt : { *(.rela.plt) }
.init : { *(.init) } =0x9090
.plt : { *(.plt) }
/* text/read-only data */
.text : { *(.text .gnu.linkonce.t.*) } :text =0x9090
.text : { *(.text .text.* .gnu.linkonce.t.*) } =0x9090
.rodata : { *(.rodata) }
.rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
/* exception unwinding - should really not be needed! XXX: find the correct place. */
__exidx_start = .;
.ARM.exidx : { *(.ARM.exidx* .gnu.linkonce.armexidx.*) }
__exidx_end = .;
/*
. = ALIGN(0x8);
altcodepatch_begin = .;
.altcodepatch : { *(.altcodepatch) }
altcodepatch_end = .;
*/
/* writable data */
. = ALIGN(0x1000);
/* writable data */
. = ALIGN (0x1000);
__data_start = .;
.data : { *(.data .gnu.linkonce.d.*) } :data
.data : { *(.data .data.* .gnu.linkonce.d.*) }
. = ALIGN(0x4);
. = ALIGN(0x8);
__ctor_list = .;
.ctors : { *(.init_array) *(.ctors) }
__ctor_end = .;
@ -66,14 +48,14 @@ SECTIONS
.dtors : { *(.fini_array) *(.dtors) }
__dtor_end = .;
.got : { *(.got.plt) *(.got) }
.dynamic : { *(.dynamic) } :dynamic :data
.dynamic : { *(.dynamic) }
/* uninitialized data (in same segment as writable data) */
__bss_start = .;
.bss : { *(.bss) }
.bss : { *(.bss .bss.* .gnu.linkonce.b.*) }
. = ALIGN(0x1000);
_end = .;
_end = . ;
/* Strip unnecessary stuff */
/DISCARD/ : { *(.comment .note .eh_frame) }