diff options
author | gkoehler <gkoehler@cvs.openbsd.org> | 2021-05-10 17:29:42 +0000 |
---|---|---|
committer | gkoehler <gkoehler@cvs.openbsd.org> | 2021-05-10 17:29:42 +0000 |
commit | c3fc5670031608bfcb0f970330e3bc119ab48333 (patch) | |
tree | 478376c8a3c0e6b302461a6a8cdeb9ebc27577e8 /sys/arch/macppc/conf | |
parent | 17d4e9d16dcbcb3af0571c80c044810817b665cc (diff) |
Add ld.script for macppc kernel, ofwboot
These are copies of powerpc64/conf/ld.script with some changes for
macppc. They work with both ld.bfd and ld.lld.
The ld.script fixes ld.lld. Without ld.script, lld would set the
symbol "etext" to a wrong value like 0x10000034, then ofwboot would
freeze and fail to boot the kernel. With ld.script, we PROVIDE a
correct etext.
ok kettenis@
Diffstat (limited to 'sys/arch/macppc/conf')
-rw-r--r-- | sys/arch/macppc/conf/Makefile.macppc | 4 | ||||
-rw-r--r-- | sys/arch/macppc/conf/ld.script | 68 |
2 files changed, 70 insertions, 2 deletions
diff --git a/sys/arch/macppc/conf/Makefile.macppc b/sys/arch/macppc/conf/Makefile.macppc index 9db16c54b2a..96c49bc75d8 100644 --- a/sys/arch/macppc/conf/Makefile.macppc +++ b/sys/arch/macppc/conf/Makefile.macppc @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile.macppc,v 1.101 2021/01/28 17:39:03 deraadt Exp $ +# $OpenBSD: Makefile.macppc,v 1.102 2021/05/10 17:29:41 gkoehler Exp $ # For instructions on building kernels consult the config(8) and options(4) # manual pages. @@ -51,7 +51,7 @@ DEBUG?= -g COPTIMIZE?= -O2 CFLAGS= ${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTIMIZE} ${COPTS} ${PIPE} AFLAGS= -D_LOCORE ${CMACHFLAGS} -LINKFLAGS= -N -Ttext 100114 -e start --warn-common -nopie +LINKFLAGS= -N -T ld.script --warn-common -nopie .if ${MACHINE} == "powerpc64" CFLAGS+= -m32 diff --git a/sys/arch/macppc/conf/ld.script b/sys/arch/macppc/conf/ld.script index e69de29bb2d..5d0127a8366 100644 --- a/sys/arch/macppc/conf/ld.script +++ b/sys/arch/macppc/conf/ld.script @@ -0,0 +1,68 @@ +/* $OpenBSD: ld.script,v 1.2 2021/05/10 17:29:41 gkoehler Exp $ */ + +/* + * Copyright (c) 2013 Mark Kettenis <kettenis@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +ENTRY(start) + +PHDRS +{ + text PT_LOAD; + openbsd_randomize PT_OPENBSD_RANDOMIZE; +} + +SECTIONS +{ + . = 0x00100114; + .text : + { + *(.text) + } :text + PROVIDE (etext = .); + PROVIDE (_etext = .); + + .rodata : + { + *(.rodata .rodata.*) + } :text + + .data.rel.ro : + { + *(.data.rel.ro) + } :text + + .openbsd.randomdata : + { + *(.openbsd.randomdata .openbsd.randomdata.*) + } :openbsd_randomize :text + + .data : + { + *(.data) + } :text + + .sbss : + { + *(.sbss) + } + + .bss : + { + *(.bss) + } + PROVIDE (end = .); + PROVIDE (_end = .); +} |