Merge tag 'u-boot-atmel-fixes-2020.07-a' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / arch / x86 / lib / relocate.c
index ed10755d9c1846b7313ad2e46a17b36511f97c71..ecbd0927e07cf6d55f8b30449cfb910230f9e0bd 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #include <common.h>
+#include <log.h>
 #include <relocate.h>
 #include <asm/u-boot-x86.h>
 #include <asm/sections.h>
@@ -53,6 +54,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 +101,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;