Port the EFI reloc codeto work on arm64. This used the rela relocation

table so wiill need the addend included in the relocation calculation.

Sponsored by:	The FreeBSD Foundation
This commit is contained in:
andrew 2015-04-10 09:15:35 +00:00
parent 43ee10c122
commit 469a6f6d98

View File

@ -32,7 +32,12 @@ __FBSDID("$FreeBSD$");
#include <efi.h>
#include <bootstrap.h>
#if defined(__arm__) || defined(__i386__)
#if defined(__aarch64__)
#define ElfW_Rel Elf64_Rela
#define ElfW_Dyn Elf64_Dyn
#define ELFW_R_TYPE ELF64_R_TYPE
#define ELF_RELA
#elif defined(__arm__) || defined(__i386__)
#define ElfW_Rel Elf32_Rel
#define ElfW_Dyn Elf32_Dyn
#define ELFW_R_TYPE ELF32_R_TYPE
@ -43,7 +48,10 @@ __FBSDID("$FreeBSD$");
#else
#error architecture not supported
#endif
#if defined(__amd64__)
#if defined(__aarch64__)
#define RELOC_TYPE_NONE R_AARCH64_NONE
#define RELOC_TYPE_RELATIVE R_AARCH64_RELATIVE
#elif defined(__amd64__)
#define RELOC_TYPE_NONE R_X86_64_NONE
#define RELOC_TYPE_RELATIVE R_X86_64_RELATIVE
#elif defined(__arm__)
@ -104,6 +112,10 @@ _reloc(unsigned long ImageBase, ElfW_Dyn *dynamic, EFI_HANDLE image_handle,
/* Address relative to the base address. */
newaddr = (unsigned long *)(ImageBase + rel->r_offset);
*newaddr += ImageBase;
/* Add the addend when the ABI uses them */
#ifdef ELF_RELA
*newaddr += rel->r_addend;
#endif
break;
default:
/* XXX: do we need other relocations ? */