From owner-svn-src-head@freebsd.org Sat Sep 3 15:26:31 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 7C6EABCE639; Sat, 3 Sep 2016 15:26:31 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5A547BD; Sat, 3 Sep 2016 15:26:31 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u83FQUqT017371; Sat, 3 Sep 2016 15:26:30 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u83FQSCZ017350; Sat, 3 Sep 2016 15:26:28 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201609031526.u83FQSCZ017350@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Sat, 3 Sep 2016 15:26:28 +0000 (UTC) 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 ... X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Sep 2016 15:26:31 -0000 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 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 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 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 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 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 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 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 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 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 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 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