Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Sep 2016 15:26:28 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r305353 - in head/sys/boot: i386 i386/boot0 i386/boot2 i386/btx/btx i386/btx/btxldr i386/cdboot i386/gptboot i386/gptzfsboot i386/mbr i386/pmbr i386/pxeldr i386/zfsboot pc98 pc98/boot0 ...
Message-ID:  <201609031526.u83FQSCZ017350@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Sat Sep  3 15:26:28 2016
New Revision: 305353
URL: https://svnweb.freebsd.org/changeset/base/305353

Log:
  Don't use -N to set the OMAGIC with data and text writeable and data
  not page aligned. To do this, use the ld script gnu ld installs on my
  system.
  
  This is imperfect: LDFLAGS_BIN and LD_FLAGS_BIN describe different
  things. The loader script could be better named and take into account
  other architectures. And having two different mechanisms to do
  basically the same thing needs study. However, it's blocking forward
  progress on lld, so I'll work in parallel to sort these out.
  
  Differential Revision: https://reviews.freebsd.org/D7409
  Reviewed by: emaste

Added:
  head/sys/boot/i386/boot.ldscript   (contents, props changed)
Modified:
  head/sys/boot/i386/Makefile.inc
  head/sys/boot/i386/boot0/Makefile
  head/sys/boot/i386/boot2/Makefile
  head/sys/boot/i386/btx/btx/Makefile
  head/sys/boot/i386/btx/btxldr/Makefile
  head/sys/boot/i386/cdboot/Makefile
  head/sys/boot/i386/gptboot/Makefile
  head/sys/boot/i386/gptzfsboot/Makefile
  head/sys/boot/i386/mbr/Makefile
  head/sys/boot/i386/pmbr/Makefile
  head/sys/boot/i386/pxeldr/Makefile
  head/sys/boot/i386/zfsboot/Makefile
  head/sys/boot/pc98/Makefile.inc
  head/sys/boot/pc98/boot0/Makefile
  head/sys/boot/pc98/boot2/Makefile
  head/sys/boot/pc98/btx/btx/Makefile
  head/sys/boot/pc98/btx/btxldr/Makefile
  head/sys/boot/pc98/cdboot/Makefile

Modified: head/sys/boot/i386/Makefile.inc
==============================================================================
--- head/sys/boot/i386/Makefile.inc	Sat Sep  3 15:26:00 2016	(r305352)
+++ head/sys/boot/i386/Makefile.inc	Sat Sep  3 15:26:28 2016	(r305353)
@@ -28,4 +28,9 @@ BTXLDR=		${BTXDIR}/btxldr/btxldr
 BTXKERN=	${BTXDIR}/btx/btx
 BTXCRT=		${BTXDIR}/lib/crt0.o
 
+# compact binary with no padding between text, data, bss
+LDSCRIPT=	${SRCTOP}/sys/boot/i386/boot.ldscript
+LDFLAGS_BIN=-e start -Ttext ${ORG} -Wl,-T,${LDSCRIPT},-S,--oformat,binary
+LD_FLAGS_BIN=-static -T ${LDSCRIPT} --gc-sections
+
 .include "../Makefile.inc"

Added: head/sys/boot/i386/boot.ldscript
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sys/boot/i386/boot.ldscript	Sat Sep  3 15:26:28 2016	(r305353)
@@ -0,0 +1,11 @@
+/* $FreeBSD$ */
+/* Merge text, data and bss together almost no padding */
+OUTPUT_FORMAT("elf32-i386-freebsd")
+OUTPUT_ARCH(i386)
+ENTRY(_start)
+SECTIONS {
+  . = 0x08048000 + SIZEOF_HEADERS;
+  .text : { *(.text) } =0x90909090	/* Pad with nops, if needed */
+  .data : { *(.data) } _edata = .;
+  .bss  : { *(.bss) }  _end = .;
+}

Modified: head/sys/boot/i386/boot0/Makefile
==============================================================================
--- head/sys/boot/i386/boot0/Makefile	Sat Sep  3 15:26:00 2016	(r305352)
+++ head/sys/boot/i386/boot0/Makefile	Sat Sep  3 15:26:28 2016	(r305353)
@@ -40,6 +40,7 @@ BOOT_BOOT0_TICKS?=	0xb6
 # The base address that we the boot0 code to to run it.  Don't change this
 # unless you are glutton for punishment.
 BOOT_BOOT0_ORG?=	0x600
+ORG=${BOOT_BOOT0_ORG}
 
 # Comm settings for boot0sio.
 # Bit(s) Description
@@ -74,7 +75,7 @@ CFLAGS+=-DFLAGS=${BOOT_BOOT0_FLAGS} \
 	-DTICKS=${BOOT_BOOT0_TICKS} \
 	-DCOMSPEED=${BOOT_BOOT0_COMCONSOLE_SPEED}
 
-LDFLAGS=-e start -Ttext ${BOOT_BOOT0_ORG} -Wl,-N,-S,--oformat,binary
+LDFLAGS=${LDFLAGS_BIN}
 
 .include <bsd.prog.mk>
 

Modified: head/sys/boot/i386/boot2/Makefile
==============================================================================
--- head/sys/boot/i386/boot2/Makefile	Sat Sep  3 15:26:00 2016	(r305352)
+++ head/sys/boot/i386/boot2/Makefile	Sat Sep  3 15:26:28 2016	(r305353)
@@ -48,7 +48,7 @@ CFLAGS.gcc+=   -mno-align-long-strings
 
 CFLAGS.clang+=	-Oz ${CLANG_OPT_SMALL}
 
-LD_FLAGS=-static -N --gc-sections
+LD_FLAGS=${LD_FLAGS_BIN}
 
 # Pick up ../Makefile.inc early.
 .include <bsd.init.mk>

Modified: head/sys/boot/i386/btx/btx/Makefile
==============================================================================
--- head/sys/boot/i386/btx/btx/Makefile	Sat Sep  3 15:26:00 2016	(r305352)
+++ head/sys/boot/i386/btx/btx/Makefile	Sat Sep  3 15:26:28 2016	(r305353)
@@ -25,7 +25,7 @@ CFLAGS+=-DBTX_SERIAL -DSIOPRT=${BOOT_COM
 
 ORG=	0x9000
 
-LDFLAGS=-e start -Ttext ${ORG} -Wl,-N,-S,--oformat,binary
+LDFLAGS=${LDFLAGS_BIN}
 
 .include <bsd.prog.mk>
 

Modified: head/sys/boot/i386/btx/btxldr/Makefile
==============================================================================
--- head/sys/boot/i386/btx/btxldr/Makefile	Sat Sep  3 15:26:00 2016	(r305352)
+++ head/sys/boot/i386/btx/btxldr/Makefile	Sat Sep  3 15:26:28 2016	(r305353)
@@ -12,7 +12,8 @@ CFLAGS+=-I${.CURDIR}/../../common
 CFLAGS+=-DBTXLDR_VERBOSE
 .endif
 
-LDFLAGS=-e start -Ttext ${LOADER_ADDRESS} -Wl,-N,-S,--oformat,binary
+ORG=${LOADER_ADDRESS}
+LDFLAGS=${LDFLAGS_BIN}
 
 .include <bsd.prog.mk>
 

Modified: head/sys/boot/i386/cdboot/Makefile
==============================================================================
--- head/sys/boot/i386/cdboot/Makefile	Sat Sep  3 15:26:00 2016	(r305352)
+++ head/sys/boot/i386/cdboot/Makefile	Sat Sep  3 15:26:28 2016	(r305353)
@@ -10,7 +10,7 @@ CFLAGS+=-I${.CURDIR}/../common
 
 ORG=	0x7c00
 
-LDFLAGS=-e start -Ttext ${ORG} -Wl,-N,-S,--oformat,binary
+LDFLAGS=${LDFLAGS_BIN}
 
 .include <bsd.prog.mk>
 

Modified: head/sys/boot/i386/gptboot/Makefile
==============================================================================
--- head/sys/boot/i386/gptboot/Makefile	Sat Sep  3 15:26:00 2016	(r305352)
+++ head/sys/boot/i386/gptboot/Makefile	Sat Sep  3 15:26:28 2016	(r305353)
@@ -47,7 +47,7 @@ LIBGELIBOOT=	${.OBJDIR}/../../geli/libge
 OPENCRYPTO_XTS=	xform_aes_xts.o
 .endif
 
-LD_FLAGS=-static -N --gc-sections
+LD_FLAGS=${LD_FLAGS_BIN}
 
 LIBSTAND=	${.OBJDIR}/../../libstand32/libstand.a
 

Modified: head/sys/boot/i386/gptzfsboot/Makefile
==============================================================================
--- head/sys/boot/i386/gptzfsboot/Makefile	Sat Sep  3 15:26:00 2016	(r305352)
+++ head/sys/boot/i386/gptzfsboot/Makefile	Sat Sep  3 15:26:28 2016	(r305353)
@@ -46,7 +46,7 @@ OPENCRYPTO_XTS=	xform_aes_xts.o
 
 CFLAGS.gcc+=	--param max-inline-insns-single=100
 
-LD_FLAGS=-static -N --gc-sections
+LD_FLAGS=${LD_FLAGS_BIN}
 
 LIBSTAND=	${.OBJDIR}/../../libstand32/libstand.a
 

Modified: head/sys/boot/i386/mbr/Makefile
==============================================================================
--- head/sys/boot/i386/mbr/Makefile	Sat Sep  3 15:26:00 2016	(r305352)
+++ head/sys/boot/i386/mbr/Makefile	Sat Sep  3 15:26:28 2016	(r305353)
@@ -12,6 +12,6 @@ BOOT_MBR_FLAGS?=	0x80
 ORG=	0x600
 
 AFLAGS+=--defsym FLAGS=${BOOT_MBR_FLAGS}
-LDFLAGS=-e start -Ttext ${ORG} -Wl,-N,-S,--oformat,binary
+LDFLAGS=${LDFLAGS_BIN}
 
 .include <bsd.prog.mk>

Modified: head/sys/boot/i386/pmbr/Makefile
==============================================================================
--- head/sys/boot/i386/pmbr/Makefile	Sat Sep  3 15:26:00 2016	(r305352)
+++ head/sys/boot/i386/pmbr/Makefile	Sat Sep  3 15:26:28 2016	(r305353)
@@ -9,6 +9,6 @@ SRCS=	${PROG}.s
 ORG=	0x600
 
 AFLAGS+=--defsym FLAGS=${BOOT_MBR_FLAGS}
-LDFLAGS=-e start -Ttext ${ORG} -Wl,-N,-S,--oformat,binary
+LDFLAGS=${LDFLAGS_BIN}
 
 .include <bsd.prog.mk>

Modified: head/sys/boot/i386/pxeldr/Makefile
==============================================================================
--- head/sys/boot/i386/pxeldr/Makefile	Sat Sep  3 15:26:00 2016	(r305352)
+++ head/sys/boot/i386/pxeldr/Makefile	Sat Sep  3 15:26:28 2016	(r305353)
@@ -34,7 +34,7 @@ ${BOOT}: ${LDR} ${LOADER}
 	dd if=${.TARGET}.tmp of=${.TARGET} obs=2k conv=osync status=none
 	rm ${.TARGET}.tmp
 
-LDFLAGS+=-e start -Ttext ${ORG} -Wl,-N,-S,--oformat,binary
+LDFLAGS+=${LDFLAGS_BIN}
 
 CLEANFILES+= ${LOADER}
 

Modified: head/sys/boot/i386/zfsboot/Makefile
==============================================================================
--- head/sys/boot/i386/zfsboot/Makefile	Sat Sep  3 15:26:00 2016	(r305352)
+++ head/sys/boot/i386/zfsboot/Makefile	Sat Sep  3 15:26:28 2016	(r305353)
@@ -36,7 +36,7 @@ CFLAGS=	-DBOOTPROG=\"zfsboot\" \
 
 CFLAGS.gcc+=	--param max-inline-insns-single=100
 
-LD_FLAGS=-static -N --gc-sections
+LD_FLAGS=${LD_FLAGS_BIN}
 
 LIBSTAND=	${.OBJDIR}/../../libstand32/libstand.a
 

Modified: head/sys/boot/pc98/Makefile.inc
==============================================================================
--- head/sys/boot/pc98/Makefile.inc	Sat Sep  3 15:26:00 2016	(r305352)
+++ head/sys/boot/pc98/Makefile.inc	Sat Sep  3 15:26:28 2016	(r305353)
@@ -21,4 +21,9 @@ BTXLDR=		${BTXDIR}/btxldr/btxldr
 BTXKERN=	${BTXDIR}/btx/btx
 BTXCRT=		${BTXDIR}/lib/crt0.o
 
+# compact binary with no padding between text, data, bss
+LDSCRIPT=	${SRCTOP}/sys/boot/i386/boot.ldscript
+LDFLAGS_BIN=-e start -Ttext ${ORG} -Wl,-T,${LDSCRIPT},-S,--oformat,binary
+LD_FLAGS_BIN=-static -T ${LDSCRIPT} --gc-sections
+
 .include "../Makefile.inc"

Modified: head/sys/boot/pc98/boot0/Makefile
==============================================================================
--- head/sys/boot/pc98/boot0/Makefile	Sat Sep  3 15:26:00 2016	(r305352)
+++ head/sys/boot/pc98/boot0/Makefile	Sat Sep  3 15:26:28 2016	(r305353)
@@ -1,6 +1,6 @@
 # $FreeBSD$
 
-PROG=	${BOOT}.out
+PROG=	${BOOT}
 INTERNALPROG=
 FILES=	${BOOT}
 MAN=
@@ -12,10 +12,8 @@ BOOT=	boot0
 # The base address that we the boot0 code to to run it.  Don't change this
 # unless you are glutton for punishment.
 BOOT_BOOT0_ORG?=	0x0000
+ORG=${BOOT_BOOT0_ORG}
 
-LDFLAGS=-e start -Ttext ${BOOT_BOOT0_ORG} -Wl,-N
-
-${BOOT}: ${BOOT}.out
-	${OBJCOPY} -S -O binary ${BOOT}.out ${.TARGET}
+LDFLAGS=${LDFLAGS_BIN}
 
 .include <bsd.prog.mk>

Modified: head/sys/boot/pc98/boot2/Makefile
==============================================================================
--- head/sys/boot/pc98/boot2/Makefile	Sat Sep  3 15:26:00 2016	(r305352)
+++ head/sys/boot/pc98/boot2/Makefile	Sat Sep  3 15:26:28 2016	(r305353)
@@ -52,7 +52,7 @@ CFLAGS.gcc+=   -mno-align-long-strings
 
 CFLAGS.clang+=	-Oz ${CLANG_OPT_SMALL}
 
-LD_FLAGS=-static -N --gc-sections
+LD_FLAGS=${LD_FLAGS_BIN}
 
 # Pick up ../Makefile.inc early.
 .include <bsd.init.mk>

Modified: head/sys/boot/pc98/btx/btx/Makefile
==============================================================================
--- head/sys/boot/pc98/btx/btx/Makefile	Sat Sep  3 15:26:00 2016	(r305352)
+++ head/sys/boot/pc98/btx/btx/Makefile	Sat Sep  3 15:26:28 2016	(r305353)
@@ -25,7 +25,7 @@ CFLAGS+=-DBTX_SERIAL -DSIOPRT=${BOOT_COM
 
 ORG=	0x9000
 
-LDFLAGS=-e start -Ttext ${ORG} -Wl,-N,-S,--oformat,binary
+LDFLAGS=${LDFLAGS_BIN}
 
 .include <bsd.prog.mk>
 

Modified: head/sys/boot/pc98/btx/btxldr/Makefile
==============================================================================
--- head/sys/boot/pc98/btx/btxldr/Makefile	Sat Sep  3 15:26:00 2016	(r305352)
+++ head/sys/boot/pc98/btx/btxldr/Makefile	Sat Sep  3 15:26:28 2016	(r305353)
@@ -12,7 +12,8 @@ CFLAGS+=-I${.CURDIR}/../../../i386/commo
 CFLAGS+=-DBTXLDR_VERBOSE
 .endif
 
-LDFLAGS=-e start -Ttext ${LOADER_ADDRESS} -Wl,-N,-S,--oformat,binary
+ORG=${LOADER_ADDRESS}
+LDFLAGS=${LDFLAGS_BIN}
 
 .include <bsd.prog.mk>
 

Modified: head/sys/boot/pc98/cdboot/Makefile
==============================================================================
--- head/sys/boot/pc98/cdboot/Makefile	Sat Sep  3 15:26:00 2016	(r305352)
+++ head/sys/boot/pc98/cdboot/Makefile	Sat Sep  3 15:26:28 2016	(r305353)
@@ -10,7 +10,7 @@ CFLAGS+=-I${.CURDIR}/../../i386/common
 
 ORG=	0x0000
 
-LDFLAGS=-e start -Ttext ${ORG} -Wl,-N,-S,--oformat,binary
+LDFLAGS=${LDFLAGS_BIN}
 
 .include <bsd.prog.mk>
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201609031526.u83FQSCZ017350>