Skip to content

Commit

Permalink
HBSD: Enable PIEified base for ARM64.
Browse files Browse the repository at this point in the history
FreeBSD doesn't support Position-Independent Code in the loader stages
on ARM64 (yet?). Move a couple things around and disable PICification
and PIEification of the loader bits on ARM64. I'd assume that the same
thing would need to happen for ARM, but I'd like that architecture to
die the same death I wish upon i386.

Signed-off-by:	Shawn Webb <shawn.webb@hardenedbsd.org>
  • Loading branch information
lattera committed Apr 18, 2016
1 parent 4b99d47 commit eba7041
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/libstand/Makefile
Expand Up @@ -9,6 +9,7 @@
PACKAGE=lib${LIB} PACKAGE=lib${LIB}
MK_PROFILE= no MK_PROFILE= no
MK_SSP= no MK_SSP= no
NO_PIC=


.include <src.opts.mk> .include <src.opts.mk>


Expand All @@ -17,7 +18,6 @@ LIBSTAND_CPUARCH?=${MACHINE_CPUARCH}
LIBC_SRC= ${LIBSTAND_SRC}/../libc LIBC_SRC= ${LIBSTAND_SRC}/../libc


LIB= stand LIB= stand
NO_PIC=
INCS?= stand.h INCS?= stand.h
MAN?= libstand.3 MAN?= libstand.3


Expand Down
2 changes: 1 addition & 1 deletion share/mk/src.opts.mk
Expand Up @@ -256,7 +256,7 @@ BROKEN_OPTIONS+=LLDB
BROKEN_OPTIONS+=LIBSOFT BROKEN_OPTIONS+=LIBSOFT
.endif .endif


.if ${__T} == "amd64" || ${__T} == "i386" .if ${__T} == "amd64" || ${__T} == "i386" || ${__T} == "aarch64"
__DEFAULT_YES_OPTIONS+=PIE __DEFAULT_YES_OPTIONS+=PIE
.else .else
__DEFAULT_NO_OPTIONS+=PIE __DEFAULT_NO_OPTIONS+=PIE
Expand Down
1 change: 1 addition & 0 deletions sys/boot/common/Makefile.inc
Expand Up @@ -11,6 +11,7 @@ SRCS+= load_elf64.c load_elf64_obj.c reloc_elf64.c
SRCS+= load_elf32.c load_elf32_obj.c reloc_elf32.c SRCS+= load_elf32.c load_elf32_obj.c reloc_elf32.c
.elif ${MACHINE_CPUARCH} == "aarch64" .elif ${MACHINE_CPUARCH} == "aarch64"
SRCS+= load_elf64.c reloc_elf64.c SRCS+= load_elf64.c reloc_elf64.c
NOPIE= 1
.elif ${MACHINE_CPUARCH} == "arm" .elif ${MACHINE_CPUARCH} == "arm"
SRCS+= load_elf32.c reloc_elf32.c SRCS+= load_elf32.c reloc_elf32.c
.elif ${MACHINE_CPUARCH} == "powerpc" .elif ${MACHINE_CPUARCH} == "powerpc"
Expand Down
4 changes: 4 additions & 0 deletions sys/boot/efi/boot1/Makefile
Expand Up @@ -2,6 +2,10 @@


MAN= MAN=


.if ${MACHINE_CPUARCH} == "aarch64"
NOPIE= 1
.endif

.include <src.opts.mk> .include <src.opts.mk>


MK_SSP= no MK_SSP= no
Expand Down
1 change: 1 addition & 0 deletions sys/boot/efi/libefi/Makefile
Expand Up @@ -9,6 +9,7 @@ SRCS= delay.c efi_console.c efinet.c efipart.c errno.c handles.c \


.if ${MACHINE_CPUARCH} == "aarch64" .if ${MACHINE_CPUARCH} == "aarch64"
CFLAGS+= -msoft-float -mgeneral-regs-only CFLAGS+= -msoft-float -mgeneral-regs-only
NOPIE= 1
.endif .endif
.if ${MACHINE_ARCH} == "amd64" .if ${MACHINE_ARCH} == "amd64"
CFLAGS+= -fPIC -mno-red-zone CFLAGS+= -fPIC -mno-red-zone
Expand Down
4 changes: 4 additions & 0 deletions sys/boot/efi/loader/Makefile
Expand Up @@ -2,6 +2,10 @@


MAN= MAN=


.if ${MACHINE_CPUARCH} == "aarch64"
NOPIE= 1
.endif

.include <src.opts.mk> .include <src.opts.mk>


MK_SSP= no MK_SSP= no
Expand Down
2 changes: 2 additions & 0 deletions sys/boot/efi/loader/arch/arm64/Makefile.inc
Expand Up @@ -22,3 +22,5 @@ loader.help: help.common


FILES+= loader.rc FILES+= loader.rc
.endif .endif

NOPIE= 1
4 changes: 4 additions & 0 deletions sys/boot/fdt/Makefile
Expand Up @@ -26,5 +26,9 @@ CFLAGS+= -m32


CFLAGS+= -Wformat -Wall CFLAGS+= -Wformat -Wall


.if ${MACHINE_CPUARCH} == "aarch64"
NOPIE= 1
.endif

.include <bsd.stand.mk> .include <bsd.stand.mk>
.include <bsd.lib.mk> .include <bsd.lib.mk>
4 changes: 4 additions & 0 deletions sys/boot/ficl/Makefile
Expand Up @@ -3,6 +3,10 @@


FICLDIR?= ${.CURDIR} FICLDIR?= ${.CURDIR}


.if ${MACHINE_CPUARCH} == "aarch64"
NOPIE= 1
.endif

.if defined(FICL32) .if defined(FICL32)
.PATH: ${FICLDIR}/${MACHINE_CPUARCH:S/amd64/i386/} .PATH: ${FICLDIR}/${MACHINE_CPUARCH:S/amd64/i386/}
.elif ${MACHINE_ARCH} == "mips64" || ${MACHINE_ARCH} == "mips64el" .elif ${MACHINE_ARCH} == "mips64" || ${MACHINE_ARCH} == "mips64el"
Expand Down
3 changes: 3 additions & 0 deletions sys/boot/usb/Makefile
Expand Up @@ -51,6 +51,9 @@ CFLAGS+= -m32
.if ${MACHINE_CPUARCH} == "mips" .if ${MACHINE_CPUARCH} == "mips"
CFLAGS+= -mno-abicalls CFLAGS+= -mno-abicalls
.endif .endif
.if ${MACHINE_CPUARCH} == "aarch64"
NOPIE= 1
.endif




.include "usbcore.mk" .include "usbcore.mk"
Expand Down

0 comments on commit eba7041

Please sign in to comment.