svn commit: r281357 - head/sys/boot/efi/loader

Andrew Turner andrew at FreeBSD.org
Fri Apr 10 09:15:37 UTC 2015


Author: andrew
Date: Fri Apr 10 09:15:35 2015
New Revision: 281357
URL: https://svnweb.freebsd.org/changeset/base/281357

Log:
  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

Modified:
  head/sys/boot/efi/loader/reloc.c

Modified: head/sys/boot/efi/loader/reloc.c
==============================================================================
--- head/sys/boot/efi/loader/reloc.c	Fri Apr 10 08:01:49 2015	(r281356)
+++ head/sys/boot/efi/loader/reloc.c	Fri Apr 10 09:15:35 2015	(r281357)
@@ -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
 			/* 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 ? */


More information about the svn-src-all mailing list