aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2020-01-17 13:44:50 +0900
committerMasahiro Yamada <yamada.masahiro@socionext.com>2020-01-24 22:34:25 +0900
commit511046eaa28f89d0ae1d8577bc940ad02d129f19 (patch)
treefb42946474828ed4e9102d050aa633b94912bcb5
parent320920c15f7b828e34f874c4afb8fa78a3dccb71 (diff)
downloadplatform_external_arm-trusted-firmware-511046eaa28f89d0ae1d8577bc940ad02d129f19.tar.gz
platform_external_arm-trusted-firmware-511046eaa28f89d0ae1d8577bc940ad02d129f19.tar.bz2
platform_external_arm-trusted-firmware-511046eaa28f89d0ae1d8577bc940ad02d129f19.zip
BL31: discard .dynsym .dynstr .hash sections to make ENABLE_PIE work
When I tried ENABLE_PIE for my PLAT=uniphier platform, BL31 crashed at its entry. When it is built with ENABLE_PIE=1, some sections are inserted before the executable code. $ make PLAT=uniphier CROSS_COMPILE=aarch64-linux-gnu- ENABLE_PIE=1 bl31 $ aarch64-linux-gnu-objdump -h build/uniphier/release/bl31/bl31.elf | head -n 13 build/uniphier/release/bl31/bl31.elf: file format elf64-littleaarch64 Sections: Idx Name Size VMA LMA File off Algn 0 .dynsym 000002a0 0000000081000000 0000000081000000 00010000 2**3 CONTENTS, ALLOC, LOAD, READONLY, DATA 1 .dynstr 000002a0 00000000810002a0 00000000810002a0 000102a0 2**0 CONTENTS, ALLOC, LOAD, READONLY, DATA 2 .hash 00000124 0000000081000540 0000000081000540 00010540 2**3 CONTENTS, ALLOC, LOAD, READONLY, DATA 3 ro 0000699c 0000000081000664 0000000081000664 00010664 2**11 CONTENTS, ALLOC, LOAD, CODE The previous stage loader generally jumps over to the base address of BL31, where no valid instruction exists. I checked the linker script of Linux (arch/arm64/kernel/vmlinux.lds.S) and U-Boot (arch/arm/cpu/armv8/u-boot.lds), both of which support relocation. They simply discard those sections. Do similar in TF-A too. Change-Id: I6c33e9143856765d4ffa24f3924b0ab51a17cde9 Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
-rw-r--r--bl31/bl31.ld.S4
1 files changed, 4 insertions, 0 deletions
diff --git a/bl31/bl31.ld.S b/bl31/bl31.ld.S
index 42227f0f3..c7185a893 100644
--- a/bl31/bl31.ld.S
+++ b/bl31/bl31.ld.S
@@ -339,6 +339,10 @@ SECTIONS
__RW_END__ = .;
__BL31_END__ = .;
+ /DISCARD/ : {
+ *(.dynsym .dynstr .hash .gnu.hash)
+ }
+
ASSERT(. <= BL31_LIMIT, "BL31 image has exceeded its limit.")
#endif
}