]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[build] Allow elf2efi.c to build on FreeBSD
authorMichael Brown <mcb30@ipxe.org>
Sat, 30 Jan 2021 00:11:33 +0000 (00:11 +0000)
committerMichael Brown <mcb30@ipxe.org>
Sat, 30 Jan 2021 00:11:33 +0000 (00:11 +0000)
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>
src/util/elf2efi.c

index 4f517d7d25e1af72cab02541134cd0542641160c..38eb299642677e9d09287d4731e88d4abe590db3 100644 (file)
@@ -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
 
 #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
 #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 {