From 8678a430663ffb2e6ac0548c525cba8e5da67009 Mon Sep 17 00:00:00 2001 From: Marcel Moolenaar Date: Wed, 27 Feb 2008 00:03:23 +0000 Subject: [PATCH] Avoid hardcoding the kernel link address in the linker script. Use KERNBASE instead. While here, move the text sections forward to the beginning of the text segment. --- sys/conf/ldscript.powerpc | 25 +++++++++++++++---------- sys/powerpc/aim/locore.S | 6 ++++++ sys/powerpc/powerpc/genassym.c | 1 + 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/sys/conf/ldscript.powerpc b/sys/conf/ldscript.powerpc index fac182df7633..b7038bf256de 100644 --- a/sys/conf/ldscript.powerpc +++ b/sys/conf/ldscript.powerpc @@ -10,7 +10,20 @@ PROVIDE (__stack = 0); SECTIONS { /* Read-only sections, merged into text segment: */ - . = 0x00100000 + SIZEOF_HEADERS; + + . = kernbase + SIZEOF_HEADERS; + + .text : + { + *(.text) + *(.stub) + /* .gnu.warning sections are handled specially by elf32.em. */ + *(.gnu.warning) + *(.gnu.linkonce.t*) + } =0 + _etext = .; + PROVIDE (etext = .); + .interp : { *(.interp) } .hash : { *(.hash) } .dynsym : { *(.dynsym) } @@ -37,15 +50,7 @@ SECTIONS .rela.sbss : { *(.rela.sbss) } .rela.sdata2 : { *(.rela.sdata2) } .rela.sbss2 : { *(.rela.sbss2) } - .text : - { - *(.text) - /* .gnu.warning sections are handled specially by elf32.em. */ - *(.gnu.warning) - *(.gnu.linkonce.t*) - } =0 - _etext = .; - PROVIDE (etext = .); + .init : { *(.init) } =0 .fini : { *(.fini) } =0 .rodata : { *(.rodata) *(.gnu.linkonce.r*) } diff --git a/sys/powerpc/aim/locore.S b/sys/powerpc/aim/locore.S index 98864fb62fbd..e566e4defdb6 100644 --- a/sys/powerpc/aim/locore.S +++ b/sys/powerpc/aim/locore.S @@ -71,6 +71,12 @@ #define GET_CPUINFO(r) \ mfsprg0 r +/* + * Compiled KERNBASE location and the kernel load address + */ + .globl kernbase + .set kernbase, KERNBASE + /* * Globals */ diff --git a/sys/powerpc/powerpc/genassym.c b/sys/powerpc/powerpc/genassym.c index 5c276b1436d7..57abec1c57cb 100644 --- a/sys/powerpc/powerpc/genassym.c +++ b/sys/powerpc/powerpc/genassym.c @@ -152,4 +152,5 @@ ASSYM(TDF_NEEDRESCHED, TDF_NEEDRESCHED); ASSYM(SF_UC, offsetof(struct sigframe, sf_uc)); +ASSYM(KERNBASE, KERNBASE); ASSYM(MAXCOMLEN, MAXCOMLEN);