arm-trusted-firmware/bl31
Masahiro Yamada 511046eaa2 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>
2020-01-24 22:34:25 +09:00
..
aarch64 Prevent speculative execution past ERET 2020-01-22 21:42:51 +00:00
bl31.ld.S BL31: discard .dynsym .dynstr .hash sections to make ENABLE_PIE work 2020-01-24 22:34:25 +09:00
bl31.mk Merge "debugfs: add 9p device interface" into integration 2019-12-20 18:10:50 +00:00
bl31_context_mgmt.c Sanitise includes across codebase 2019-01-04 10:43:17 +00:00
bl31_main.c Refactor ARMv8.3 Pointer Authentication support code 2019-09-13 14:11:59 +01:00
ehf.c Minor changes to documentation and comments 2019-02-28 13:35:21 +00:00
interrupt_mgmt.c Sanitise includes across codebase 2019-01-04 10:43:17 +00:00