freebsd-dev/sys/boot/amd64/efi/Makefile
John Baldwin 7939325215 Allow the EFI loader to work with large kernels and/or modules
(for example, a large mfsroot).  Note that for EFI the kernel and
modules (as well as other metadata files such as splash screens or
memory disk images) are loaded into a statically-sized staging area.
When the EFI loader exits it copies this staging area down to the
location the kernel expects to run at.
- Add bounds checking to the copy routines to fail attempts to access
  memory outside of the staging area.  Previously loading a combined
  kernel + modules larger than the staging size (32MB) would overflow
  the staging area trashing whatever memory was afterwards.  Under
  Intel's OVMF firmware for qemu this resulted in fatal faults in the
  firmware itself.  Now the attempt will fail with ENOMEM.
- Allow the staging area size to be configured at compile time via
  an EFI_STAGING_SIZE variable in src.conf or on the command line.
  It accepts the size of the staging area in MB.  The default size
  remains 32MB.

MFC after:	2 weeks
Sponsored by:	Cisco Systems, Inc.
2015-03-12 17:07:24 +00:00

106 lines
2.3 KiB
Makefile

# $FreeBSD$
MAN=
.include <src.opts.mk>
# In-tree GCC does not support __attribute__((ms_abi)).
.if ${COMPILER_TYPE} != "gcc"
MK_SSP= no
PROG= loader.sym
INTERNALPROG=
# architecture-specific loader code
SRCS= autoload.c \
bootinfo.c \
conf.c \
copy.c \
devicename.c \
elf64_freebsd.c \
framebuffer.c \
main.c \
reloc.c \
vers.c
SRCS+= amd64_tramp.S \
start.S
CFLAGS+= -fPIC
CFLAGS+= -I.
CFLAGS+= -I${.CURDIR}/../../efi/include
CFLAGS+= -I${.CURDIR}/../../efi/include/${MACHINE_CPUARCH}
CFLAGS+= -I${.CURDIR}/../../../contrib/dev/acpica/include
CFLAGS+= -I${.CURDIR}/../../..
.if ${MK_FORTH} != "no"
BOOT_FORTH= yes
CFLAGS+= -DBOOT_FORTH
CFLAGS+= -I${.CURDIR}/../../ficl
CFLAGS+= -I${.CURDIR}/../../ficl/${MACHINE_CPUARCH}
LIBFICL= ${.OBJDIR}/../../ficl/libficl.a
.endif
# Include bcache code.
HAVE_BCACHE= yes
.if defined(EFI_STAGING_SIZE)
CFLAGS+= -DEFI_STAGING_SIZE=${EFI_STAGING_SIZE}
.endif
# Always add MI sources
.PATH: ${.CURDIR}/../../common
.include "${.CURDIR}/../../common/Makefile.inc"
CFLAGS+= -I${.CURDIR}/../../common
FILES= loader.efi
FILESMODE_loader.efi= ${BINMODE}
LDSCRIPT= ${.CURDIR}/ldscript.${MACHINE_CPUARCH}
LDFLAGS= -Wl,-T${LDSCRIPT} -Wl,-Bsymbolic -shared -Wl,-znocombreloc
CLEANFILES= vers.c loader.efi
NEWVERSWHAT= "EFI loader" ${MACHINE_CPUARCH}
vers.c: ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version
sh ${.CURDIR}/../../common/newvers.sh ${.CURDIR}/version ${NEWVERSWHAT}
OBJCOPY?= objcopy
OBJDUMP?= objdump
.if ${MACHINE_CPUARCH} == "amd64"
EFI_TARGET= efi-app-x86_64
.else
EFI_TARGET= efi-app-ia32
.endif
loader.efi: loader.sym
if [ `${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*' | wc -l` != 0 ]; then \
${OBJDUMP} -t ${.ALLSRC} | fgrep '*UND*'; \
exit 1; \
fi
${OBJCOPY} -j .text -j .sdata -j .data \
-j .dynamic -j .dynsym -j .rel.dyn \
-j .rela.dyn -j .reloc -j .eh_frame -j set_Xcommand_set \
--output-target=${EFI_TARGET} ${.ALLSRC} ${.TARGET}
LIBEFI= ${.OBJDIR}/../../efi/libefi/libefi.a
DPADD= ${LIBFICL} ${LIBEFI} ${LIBSTAND} ${LDSCRIPT}
LDADD= ${LIBFICL} ${LIBEFI} ${LIBSTAND}
.endif # ${COMPILER_TYPE} != "gcc"
.include <bsd.prog.mk>
beforedepend ${OBJS}: machine x86
CLEANFILES+= machine x86
machine:
ln -sf ${.CURDIR}/../../../amd64/include machine
x86:
ln -sf ${.CURDIR}/../../../x86/include x86