mirror of
https://github.com/ipxe/ipxe
synced 2025-12-11 22:11:08 +03:00
[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>
This commit is contained in:
@@ -38,6 +38,9 @@
|
|||||||
|
|
||||||
#define eprintf(...) fprintf ( stderr, __VA_ARGS__ )
|
#define eprintf(...) fprintf ( stderr, __VA_ARGS__ )
|
||||||
|
|
||||||
|
#undef ELF_R_TYPE
|
||||||
|
#undef ELF_R_SYM
|
||||||
|
|
||||||
#ifdef EFI_TARGET32
|
#ifdef EFI_TARGET32
|
||||||
|
|
||||||
#define EFI_IMAGE_NT_HEADERS EFI_IMAGE_NT_HEADERS32
|
#define EFI_IMAGE_NT_HEADERS EFI_IMAGE_NT_HEADERS32
|
||||||
@@ -72,21 +75,46 @@
|
|||||||
|
|
||||||
#define ELF_MREL( mach, type ) ( (mach) | ( (type) << 16 ) )
|
#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
|
#ifndef EM_AARCH64
|
||||||
#define EM_AARCH64 183
|
#define EM_AARCH64 183
|
||||||
|
#endif
|
||||||
|
#ifndef R_AARCH64_NONE
|
||||||
#define R_AARCH64_NONE 0
|
#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
|
#define R_AARCH64_ABS64 257
|
||||||
|
#endif
|
||||||
|
#ifndef R_AARCH64_CALL26
|
||||||
#define R_AARCH64_CALL26 283
|
#define R_AARCH64_CALL26 283
|
||||||
|
#endif
|
||||||
|
#ifndef R_AARCH64_JUMP26
|
||||||
#define R_AARCH64_JUMP26 282
|
#define R_AARCH64_JUMP26 282
|
||||||
|
#endif
|
||||||
|
#ifndef R_AARCH64_ADR_PREL_LO21
|
||||||
#define R_AARCH64_ADR_PREL_LO21 274
|
#define R_AARCH64_ADR_PREL_LO21 274
|
||||||
|
#endif
|
||||||
|
#ifndef R_AARCH64_ADR_PREL_PG_HI21
|
||||||
#define R_AARCH64_ADR_PREL_PG_HI21 275
|
#define R_AARCH64_ADR_PREL_PG_HI21 275
|
||||||
|
#endif
|
||||||
|
#ifndef R_AARCH64_ADD_ABS_LO12_NC
|
||||||
#define R_AARCH64_ADD_ABS_LO12_NC 277
|
#define R_AARCH64_ADD_ABS_LO12_NC 277
|
||||||
|
#endif
|
||||||
|
#ifndef R_AARCH64_LDST8_ABS_LO12_NC
|
||||||
#define R_AARCH64_LDST8_ABS_LO12_NC 278
|
#define R_AARCH64_LDST8_ABS_LO12_NC 278
|
||||||
|
#endif
|
||||||
|
#ifndef R_AARCH64_LDST16_ABS_LO12_NC
|
||||||
#define R_AARCH64_LDST16_ABS_LO12_NC 284
|
#define R_AARCH64_LDST16_ABS_LO12_NC 284
|
||||||
|
#endif
|
||||||
|
#ifndef R_AARCH64_LDST32_ABS_LO12_NC
|
||||||
#define R_AARCH64_LDST32_ABS_LO12_NC 285
|
#define R_AARCH64_LDST32_ABS_LO12_NC 285
|
||||||
|
#endif
|
||||||
|
#ifndef R_AARCH64_LDST64_ABS_LO12_NC
|
||||||
#define R_AARCH64_LDST64_ABS_LO12_NC 286
|
#define R_AARCH64_LDST64_ABS_LO12_NC 286
|
||||||
#endif /* EM_AARCH64 */
|
#endif
|
||||||
#ifndef R_ARM_CALL
|
#ifndef R_ARM_CALL
|
||||||
#define R_ARM_CALL 28
|
#define R_ARM_CALL 28
|
||||||
#endif
|
#endif
|
||||||
@@ -97,11 +125,6 @@
|
|||||||
#define R_ARM_V4BX 40
|
#define R_ARM_V4BX 40
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Seems to be missing from elf.h */
|
|
||||||
#ifndef R_AARCH64_NULL
|
|
||||||
#define R_AARCH64_NULL 256
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define EFI_FILE_ALIGN 0x20
|
#define EFI_FILE_ALIGN 0x20
|
||||||
|
|
||||||
struct elf_file {
|
struct elf_file {
|
||||||
|
|||||||
Reference in New Issue
Block a user