--- a/sys/boot/i386/Makefile.inc +++ a/sys/boot/i386/Makefile.inc @@ -3,6 +3,7 @@ # $FreeBSD: release/9.0.0/sys/boot/i386/Makefile.inc 224131 2011-07-17 13:50:21Z dim $ BINDIR?= /boot +CC_AS_LD?= no LOADER_ADDRESS?=0x200000 CFLAGS+= -ffreestanding -mpreferred-stack-boundary=2 \ @@ -12,7 +13,11 @@ LDFLAGS+= -nostdlib .if ${MACHINE_CPUARCH} == "amd64" CFLAGS+= -m32 -march=i386 ACFLAGS+= -m32 +.if ${CC_AS_LD} == "yes" +LDFLAGS+= -Wl,-m,elf_i386_fbsd +.else LDFLAGS+= -m elf_i386_fbsd +.endif AFLAGS+= --32 .endif --- a/sys/boot/i386/boot0/Makefile +++ a/sys/boot/i386/boot0/Makefile @@ -5,6 +5,7 @@ STRIP= BINMODE=${NOBINMODE} NO_MAN= SRCS= ${PROG}.S +CC_AS_LD=yes # Additional options that you can specify with make OPTS="..." # (these only apply to boot0.S) --- a/sys/boot/i386/btx/btx/Makefile +++ a/sys/boot/i386/btx/btx/Makefile @@ -4,6 +4,7 @@ PROG= btx INTERNALPROG= NO_MAN= SRCS= btx.S +CC_AS_LD=yes .if defined(BOOT_BTX_NOHANG) BOOT_BTX_FLAGS=0x1 --- a/sys/boot/i386/btx/btxldr/Makefile +++ a/sys/boot/i386/btx/btxldr/Makefile @@ -4,6 +4,7 @@ PROG= btxldr INTERNALPROG= NO_MAN= SRCS= btxldr.S +CC_AS_LD=yes CFLAGS+=-DLOADER_ADDRESS=${LOADER_ADDRESS} --- a/sys/boot/i386/btx/lib/Makefile +++ a/sys/boot/i386/btx/lib/Makefile @@ -5,5 +5,6 @@ INTERNALPROG= NO_MAN= SRCS= btxcsu.s btxsys.s btxv86.s LDFLAGS=-Wl,-r +CC_AS_LD=yes .include --- a/sys/boot/i386/cdboot/Makefile +++ a/sys/boot/i386/cdboot/Makefile @@ -5,6 +5,7 @@ STRIP= BINMODE=${NOBINMODE} NO_MAN= SRCS= ${PROG}.s +CC_AS_LD=yes ORG= 0x7c00 --- a/sys/boot/i386/mbr/Makefile +++ a/sys/boot/i386/mbr/Makefile @@ -5,6 +5,7 @@ STRIP= BINMODE=${NOBINMODE} NO_MAN= SRCS= ${PROG}.s +CC_AS_LD=yes # MBR flags: 0x80 -- try packet interface (also known as EDD or LBA) BOOT_MBR_FLAGS?= 0x80 --- a/sys/boot/i386/pmbr/Makefile +++ a/sys/boot/i386/pmbr/Makefile @@ -5,6 +5,7 @@ STRIP= BINMODE=${NOBINMODE} NO_MAN= SRCS= ${PROG}.s +CC_AS_LD=yes ORG= 0x600 --- a/sys/boot/i386/pxeldr/Makefile +++ a/sys/boot/i386/pxeldr/Makefile @@ -9,6 +9,7 @@ FILES= ${BOOT} MAN= ${BOOT}.8 SRCS= ${LDR}.S CLEANFILES= ${BOOT} +CC_AS_LD=yes BOOT= pxeboot LDR= pxeldr --- a/sys/boot/pc98/btx/btx/Makefile +++ a/sys/boot/pc98/btx/btx/Makefile @@ -4,6 +4,7 @@ PROG= btx INTERNALPROG= NO_MAN= SRCS= btx.S +CC_AS_LD=yes .if defined(BOOT_BTX_NOHANG) BOOT_BTX_FLAGS=0x1 --- a/sys/boot/pc98/btx/btxldr/Makefile +++ a/sys/boot/pc98/btx/btxldr/Makefile @@ -4,6 +4,7 @@ PROG= btxldr INTERNALPROG= NO_MAN= SRCS= btxldr.S +CC_AS_LD=yes CFLAGS+=-DLOADER_ADDRESS=${LOADER_ADDRESS} --- a/sys/boot/pc98/cdboot/Makefile +++ a/sys/boot/pc98/cdboot/Makefile @@ -5,6 +5,7 @@ STRIP= BINMODE=${NOBINMODE} NO_MAN= SRCS= ${PROG}.s +CC_AS_LD=yes ORG= 0x0000