-# $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.
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
+/* $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 = .);
+}
-# $OpenBSD: Makefile,v 1.20 2020/03/16 07:02:10 otto Exp $
+# $OpenBSD: Makefile,v 1.21 2021/05/10 17:29:41 gkoehler Exp $
# $NetBSD: Makefile,v 1.2 1997/04/17 07:46:24 thorpej Exp $
S= ${.CURDIR}/../../../..
NEWVERSWHAT= "OpenFirmware Boot"
-# For now...
+# Must match . in ld.script
RELOC= 20000
-ENTRY= _start
-
CPPFLAGS+= -I. -I${.CURDIR}/../../.. -I${.CURDIR}/../../../..
CPPFLAGS+= -DRELOC=0x${RELOC} -DCONSPEED=57600
LIBS!= cd $(.CURDIR)/$(R); $(MAKE) libdep
-${PROG}: ${OBJS} ${LIBSA} ${LIBZ}
- ${LD} -nopie -znorelro -N -X -Ttext ${RELOC} -e ${ENTRY} -o ${PROG} \
+${PROG}: ${OBJS} ${LIBSA} ${LIBZ} ld.script
+ ${LD} -nopie -znorelro -N -X -T ${.CURDIR}/ld.script -o ${PROG} \
${OBJS} ${LIBS}
.include <bsd.prog.mk>
--- /dev/null
+/* $OpenBSD: ld.script,v 1.1 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;
+}
+
+SECTIONS
+{
+ /* Must match RELOC in Makefile */
+ . = 0x00020000;
+ .text :
+ {
+ *(.text)
+ } :text
+ PROVIDE (etext = .);
+ PROVIDE (_etext = .);
+
+ .rodata :
+ {
+ *(.rodata .rodata.*)
+ } :text
+
+ .data.rel.ro :
+ {
+ *(.data.rel.ro)
+ } :text
+
+ .data :
+ {
+ *(.data)
+ } :text
+
+ .sbss :
+ {
+ *(.sbss)
+ }
+
+ .bss :
+ {
+ *(.bss)
+ }
+ PROVIDE (end = .);
+ PROVIDE (_end = .);
+}