summaryrefslogtreecommitdiffstats
path: root/arch/efi/lib
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2016-04-05 09:33:25 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2016-04-07 07:29:29 +0200
commit2096b4f8a03033fa70f15c7754c1fea8ebfa50cc (patch)
treeddd9cdda6a91d6b3105cece0860442127da4004c /arch/efi/lib
parentd3b805ad9a99933ef7d25e05b223d37c36141b37 (diff)
downloadbarebox-2096b4f8a03033fa70f15c7754c1fea8ebfa50cc.tar.gz
barebox-2096b4f8a03033fa70f15c7754c1fea8ebfa50cc.tar.xz
efi: let the generic relocate code handle all relocations
Part of the barebox code and variables are put in separate sections (.barebox* and .initcall*). When this code is compiled as position independent code then the compiler creates corresponding .rela.barebox* and .rela.initcall* sections with the relocation table entries. These sections don't match the .rela.data* wildcard in the linker script. As a result, they are not added to the .rela section during linking but are added individually after it instead. And when the EFI binary is created from the ELF binary, these sections are not copied. This has two side effects: 1. The corresponding relocations are not handled by the generic relocation code. 'fixup_tables()' was added to do these relocations manually. 2. In the DYNAMIC section, the RELASZ entry contains the total size of relocations in bytes. This includes the .rela.barebox* and .rela.initcall* sections. This value is not modified when the EFI binary is created. So the value is too large. The generic relocation code in _relocate() used this value when iterating over all relocation entries. With the wrong RELASZ value it iterates beyond the end of the .rela section into uninitialized memory. After power-on this memory is zero and the relocation code interprets this as 'nothing to do', so there is no visible effect. After a soft reset, random data in that area may produce a seemingly valid relocation entry, a random address is modified and barebox crashes. This patch adds the .rela.barebox* and .rela.initcall* sections to the normal .rela section. The RELASZ now contains the correct size and the generic relocation code works correctly. 'fixup_tables()' must be removed at the same time to avoid relocating these entries twice. Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'arch/efi/lib')
-rw-r--r--arch/efi/lib/elf_x86_64_efi.lds.S2
1 files changed, 2 insertions, 0 deletions
diff --git a/arch/efi/lib/elf_x86_64_efi.lds.S b/arch/efi/lib/elf_x86_64_efi.lds.S
index 9aa4e8d829..e1bc2120fa 100644
--- a/arch/efi/lib/elf_x86_64_efi.lds.S
+++ b/arch/efi/lib/elf_x86_64_efi.lds.S
@@ -78,6 +78,8 @@ SECTIONS
.rela : {
*(.rela.data*)
+ *(.rela.barebox*)
+ *(.rela.initcall*)
*(.rela.got)
*(.rela.stab)
}