Index: sys/boot/common/self_reloc.c =================================================================== --- sys/boot/common/self_reloc.c +++ sys/boot/common/self_reloc.c @@ -31,7 +31,7 @@ #include #include -#if defined(__aarch64__) +#if defined(__aarch64__) || defined(__amd64__) #define ElfW_Rel Elf64_Rela #define ElfW_Dyn Elf64_Dyn #define ELFW_R_TYPE ELF64_R_TYPE @@ -40,10 +40,6 @@ #define ElfW_Rel Elf32_Rel #define ElfW_Dyn Elf32_Dyn #define ELFW_R_TYPE ELF32_R_TYPE -#elif defined(__amd64__) -#define ElfW_Rel Elf64_Rel -#define ElfW_Dyn Elf64_Dyn -#define ELFW_R_TYPE ELF64_R_TYPE #else #error architecture not supported #endif @@ -99,7 +95,9 @@ } /* - * Perform the actual relocation. + * Perform the actual relocation. We rely on the object having been + * linked at 0, so that the difference between the load and link + * address is the same as the load address. */ for (; relsz > 0; relsz -= relent) { switch (ELFW_R_TYPE(rel->r_info)) { @@ -110,12 +108,7 @@ case RELOC_TYPE_RELATIVE: newaddr = (Elf_Addr *)(rel->r_offset + baseaddr); #ifdef ELF_RELA - /* - * For R_AARCH64_RELATIVE we need to calculate the - * delta between the address we are run from and the - * address we are linked at. As the latter is 0 we - * just use the address we are run from for this. - */ + /* Addend relative to the base address. */ *newaddr = baseaddr + rel->r_addend; #else /* Address relative to the base address. */