
On 10/23/2018 11:13 AM, Hannes Schmelzer wrote:
On 10/13/18 3:30 AM, Heinrich Schuchardt wrote:
Currently we support only relocations of type ELF64_R_TYPE or ELF32_R_TYPE. We should be warned if other relocation types appear in the relocation sections.
This type of message has helped to identify code overwriting a relocation section before relocation and incorrect parsing of relocation tables.
Signed-off-by: Heinrich Schuchardt xypron.glpk@gmx.de
arch/x86/lib/relocate.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
diff --git a/arch/x86/lib/relocate.c b/arch/x86/lib/relocate.c index ed10755d9c..01e619d20b 100644 --- a/arch/x86/lib/relocate.c +++ b/arch/x86/lib/relocate.c @@ -53,6 +53,15 @@ static void do_elf_reloc_fixups64(unsigned int text_base, uintptr_t size, Elf64_Addr *offset_ptr_ram; do { + unsigned long long type = ELF64_R_TYPE(re_src->r_info);
+ if (type != R_X86_64_RELATIVE) { + printf("%s: unsupported relocation type 0x%llx " + "at %p, ",__func__, type, re_src); + printf("offset = 0x%llx\n", re_src->r_offset); + continue; + }
/* Get the location from the relocation entry */ offset_ptr_rom = (Elf64_Addr *)(uintptr_t)re_src->r_offset; @@ -91,6 +100,15 @@ static void do_elf_reloc_fixups32(unsigned int text_base, uintptr_t size, Elf32_Addr *offset_ptr_ram; do { + unsigned int type = ELF32_R_TYPE(re_src->r_info);
+ if (type != R_386_RELATIVE) { + printf("%s: unsupported relocation type 0x%x " + "at %p, ",__func__, type, re_src); + printf("offset = 0x%x\n", re_src->r_offset); + continue; + }
/* Get the location from the relocation entry */ offset_ptr_rom = (Elf32_Addr *)(uintptr_t)re_src->r_offset;
Hi Heinrich, i just merged recent u-boot master into my devbranch and ran it on my board:
-- U-Boot 2018.11-rc2-00728-g85a448b (Oct 23 2018 - 10:50:53 +0200)
CPU: x86, vendor AMD, device 5a2h DRAM: 119.6 MiB do_elf_reloc_fixups32: unsupported relocation type 0x1 at 0204d3d0, offset = 0x2000087 do_elf_reloc_fixups32: unsupported relocation type 0x2 at 0204d3d8, offset = 0x2000091 Bus 0: OK
now i get such relocation warnings, can you help me in this how to deal with that?
I'm starting u-boot as a payload from coreboot.
thanks!
cheers, Hannes
Hello Hannes,
thanks for reporting the problem.
There are two possible reasons:
a) The build process introduces relocations of the reported type. b) The relocation records are overwritten before relocation. This happens if you update uninitialized globals.
To analyze your problem further, please, provide instructions for building your version of U-Boot (repository, commit, config). That will allow to check for a).
Coreboot can be run on QEMU (https://www.coreboot.org/QEMU). QEMU would allow to analyze case b). Are you able to reproduce the problem with QEMU?
Best regards
Heinrich