Commit 237d873a authored by Dave Martin's avatar Dave Martin
Browse files

arm64: bti: Ensure test are not built as PIE



Compilers that generate PIE code by default will break the tests,
since they must be fully statically linked, whereas PIE requires a
dynamic linker to relocate the images at runtime.

So, forcibly disable PIE when building.

For good measure, also pass -static when linking.  With no standard
libraries and no PIE, this should make no difference, but let's
play safe.
Signed-off-by: default avatarDave Martin <Dave.Martin@arm.com>
parent 026ad4c1
......@@ -4,6 +4,7 @@
CFLAGS = -O2 -g
CPPFLAGS =
LDFLAGS =
CROSS_COMPILE = aarch64-linux-gnu-
CC = $(CROSS_COMPILE)gcc
......@@ -12,7 +13,8 @@ TESTS = btitest nobtitest
CFLAGS_NOBTI = -DBTI=0
CFLAGS_BTI = -mbranch-protection=standard -DBTI=1
CFLAGS_COMMON = -ffreestanding -Wall -Wextra -MMD $(CFLAGS)
CFLAGS_COMMON = -fno-pie -no-pie -ffreestanding -Wall -Wextra -MMD $(CFLAGS)
LDFLAGS_COMMON = -static -nostdlib $(LDFLAGS)
BTI_CC_COMMAND = \
$(CC) $(CPPFLAGS) $(CFLAGS_BTI) $(CFLAGS_COMMON) -c -o $@ $<
......@@ -60,7 +62,7 @@ nobtitest: $(NOBTI_OBJS)
CFLAGS-nobtitest = $(CFLAGS_NOBTI)
$(TESTS):
$(CC) $(CPPFLAGS) $(CFLAGS-$@) $(CFLAGS_COMMON) -nostdlib -o $@ $^
$(CC) $(CPPFLAGS) $(CFLAGS-$@) $(CFLAGS_COMMON) $(LDFLAGS_COMMON) -o $@ $^
clean: FORCE
$(RM) $(TESTS) *.[od]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment