diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2019-11-12 12:07:04 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2019-11-12 12:09:37 +0100 |
commit | b0348d677bb47bdbd368983603b3e9604528d4ed (patch) | |
tree | 9464fbd57f6c64dc597889712e763a3b2e40a6a0 /arch/arm/Makefile | |
parent | 3b8b70bfd743c303349f67c892631cb04c2b3c68 (diff) | |
download | barebox-b0348d677bb47bdbd368983603b3e9604528d4ed.tar.gz barebox-b0348d677bb47bdbd368983603b3e9604528d4ed.tar.xz |
ARM: Compile with -fPIE
Early code in barebox often runs at an address the binary is not linked
at. This causes problems for example when simple initializations in a
switch are converted to an array lookup (-ftree-switch-conversion).
These arrays are then addressed where they are linked at. Some code
where this is known to cause problems is already compiled with
-fno-tree-switch-conversion. This however is limited to single files.
This patch compiles barebox with -fPIE enabled. This causes such tables
to be looked up PC relative rather than with its absolute address. This
makes the -fno-tree-switch-conversion and -fno-jump-table options
unnecessary.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/arm/Makefile')
-rw-r--r-- | arch/arm/Makefile | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/arm/Makefile b/arch/arm/Makefile index 13e8cee286..740b0790e7 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -141,6 +141,9 @@ CPPFLAGS += -DTEXT_BASE=$(TEXT_BASE) CPPFLAGS += -fdata-sections -ffunction-sections LDFLAGS_barebox += --gc-sections +# early code often runs at addresses we are not linked at +CPPFLAGS += -fPIE + ifdef CONFIG_RELOCATABLE LDFLAGS_barebox += -pie else |