diff options
author | Andre Przywara <andre.przywara@arm.com> | 2021-12-22 18:15:59 +0000 |
---|---|---|
committer | Mark Rutland <mark.rutland@arm.com> | 2022-01-07 14:07:30 +0000 |
commit | 66cc36c96e9a91e613734cf595e8c3212128e233 (patch) | |
tree | 5cdbadd78133ed69df7dc9e577c064e2ea991f2c | |
parent | 28932c41e14d730b8b9a7310071384178611fb32 (diff) | |
download | boot-wrapper-aarch64-66cc36c96e9a91e613734cf595e8c3212128e233.tar.gz |
Makefile: Avoid .got section creation
At the moment we build the boot-wrapper with the default toolchain
settings, which has issues if that is a toolchain targeted to Linux
userland, for instance. Since boot-wrapper is rather simple, we get away
with this, *mostly*, but there is at least one case where this breaks:
Many distributions enable PIE builds by default when building GCC, so by
just calling "gcc" we build the .o files for PIE (although we don't link
them accordingly, since we use "ld" directly).
When we moved the PSCI code from assembly to C, we also introduced
global variables, which a PIE enabled GCC will put into a .got section
(global offset table), to be able to easily relocate them at runtime
(if needed). This section happens to be outside of the memory region
we reserve, so can (and will be) overwritten by Linux at some point.
Doing PSCI calls afterwards does not end well then. "memtest=1" is one
way to trigger this.
To avoid the (in our case pointless) creation of the GOT, we specify
-fno-pic and -fno-pie, to override any potential toolchain default.
This fixes boot-wrapper builds on many distro compilers, for instance
as provided by Ubuntu and Arch Linux.
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Mark Rutland <mark.rutland@arm.com>
-rw-r--r-- | Makefile.am | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am index d0a68df..3e970a3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -126,6 +126,7 @@ CPPFLAGS += $(INITRD_FLAGS) CFLAGS += -I$(top_srcdir)/include/ -I$(top_srcdir)/$(ARCH_SRC)/include/ CFLAGS += -Wall -fomit-frame-pointer CFLAGS += -ffunction-sections -fdata-sections +CFLAGS += -fno-pic -fno-pie LDFLAGS += --gc-sections OBJ := $(addprefix $(ARCH_SRC),$(ARCH_OBJ)) $(addprefix $(COMMON_SRC),$(COMMON_OBJ)) |