aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2021-01-30 00:11:33 +0000
committerMichael Brown <mcb30@ipxe.org>2021-01-30 00:11:33 +0000
commitf034ae59f63b1ac279981e6de3f1e67ca8bbe3a0 (patch)
tree0c8df20b16e07777ef36fe08958995f5e0982902
parent25b675c3db2120aed06f05c0b0cec4b9939d7f76 (diff)
downloadipxe-f034ae59f63b1ac279981e6de3f1e67ca8bbe3a0.zip
ipxe-f034ae59f63b1ac279981e6de3f1e67ca8bbe3a0.tar.gz
ipxe-f034ae59f63b1ac279981e6de3f1e67ca8bbe3a0.tar.bz2
[build] Allow elf2efi.c to build on FreeBSD
The elf.h on FreeBSD defines ELF_R_TYPE and ELF_R_SYM (based on the host platform) and omits some but not all of the AArch64 relocation types. Fix by undefining ELF_R_TYPE and ELF_R_SYM in favour of our own definitions, and by placing each potentially missing relocation type within an individual #ifdef guard. Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/util/elf2efi.c37
1 files changed, 30 insertions, 7 deletions
diff --git a/src/util/elf2efi.c b/src/util/elf2efi.c
index 4f517d7..38eb299 100644
--- a/src/util/elf2efi.c
+++ b/src/util/elf2efi.c
@@ -38,6 +38,9 @@
#define eprintf(...) fprintf ( stderr, __VA_ARGS__ )
+#undef ELF_R_TYPE
+#undef ELF_R_SYM
+
#ifdef EFI_TARGET32
#define EFI_IMAGE_NT_HEADERS EFI_IMAGE_NT_HEADERS32
@@ -72,21 +75,46 @@
#define ELF_MREL( mach, type ) ( (mach) | ( (type) << 16 ) )
-/* Allow for building with older versions of elf.h */
+/* Provide constants missing on some platforms */
#ifndef EM_AARCH64
#define EM_AARCH64 183
+#endif
+#ifndef R_AARCH64_NONE
#define R_AARCH64_NONE 0
+#endif
+#ifndef R_AARCH64_NULL
+#define R_AARCH64_NULL 256
+#endif
+#ifndef R_AARCH64_ABS64
#define R_AARCH64_ABS64 257
+#endif
+#ifndef R_AARCH64_CALL26
#define R_AARCH64_CALL26 283
+#endif
+#ifndef R_AARCH64_JUMP26
#define R_AARCH64_JUMP26 282
+#endif
+#ifndef R_AARCH64_ADR_PREL_LO21
#define R_AARCH64_ADR_PREL_LO21 274
+#endif
+#ifndef R_AARCH64_ADR_PREL_PG_HI21
#define R_AARCH64_ADR_PREL_PG_HI21 275
+#endif
+#ifndef R_AARCH64_ADD_ABS_LO12_NC
#define R_AARCH64_ADD_ABS_LO12_NC 277
+#endif
+#ifndef R_AARCH64_LDST8_ABS_LO12_NC
#define R_AARCH64_LDST8_ABS_LO12_NC 278
+#endif
+#ifndef R_AARCH64_LDST16_ABS_LO12_NC
#define R_AARCH64_LDST16_ABS_LO12_NC 284
+#endif
+#ifndef R_AARCH64_LDST32_ABS_LO12_NC
#define R_AARCH64_LDST32_ABS_LO12_NC 285
+#endif
+#ifndef R_AARCH64_LDST64_ABS_LO12_NC
#define R_AARCH64_LDST64_ABS_LO12_NC 286
-#endif /* EM_AARCH64 */
+#endif
#ifndef R_ARM_CALL
#define R_ARM_CALL 28
#endif
@@ -97,11 +125,6 @@
#define R_ARM_V4BX 40
#endif
-/* Seems to be missing from elf.h */
-#ifndef R_AARCH64_NULL
-#define R_AARCH64_NULL 256
-#endif
-
#define EFI_FILE_ALIGN 0x20
struct elf_file {