diff --git a/src/Makefile b/src/Makefile index 1651a20..5a4333f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -49,7 +49,12 @@ CCDEFS := $(shell $(CC) -E -x c -c /dev/null -dM | $(CUT) -d" " -f2) # Detect compiler type # -ifeq ($(filter __GNUC__,$(CCDEFS)),__GNUC__) +ifeq ($(filter __clang__,$(CCDEFS)),__clang__) +CC_i386 ?= $(CC) -target i386 +CC_x86_64 ?= $(CC) -target x86_64 +CC_arm64 ?= $(CC) -target aarch64 +CFLAGS += -Wno-unused-command-line-argument +else ifeq ($(filter __GNUC__,$(CCDEFS)),__GNUC__) CC := gcc endif @@ -102,6 +107,7 @@ ifneq ($(DEBUG),) CFLAGS += -DDEBUG=$(DEBUG) endif CFLAGS += $(EXTRA_CFLAGS) +LDFLAGS += --no-relax # Build flags for i386 target # @@ -153,6 +159,10 @@ CFLAGS_WNAB = $(call CFLAGS_TEST,$(1),-Wno-array-bounds) # CFLAGS_NLTO = $(call CFLAGS_TEST,$(1),-fno-lto) +# Inhibit address-significance table +# +CFLAGS_NAS = $(call CFLAGS_TEST,$(1),-fno-addrsig) + # Add -maccumulate-outgoing-args if required # MS_ABI_TEST_CODE := extern void __attribute__ (( ms_abi )) ms_abi(); \ @@ -167,7 +177,7 @@ endef # Conditional build flags # CFLAGS_COND = $(CFLAGS_SPG) $(CFLAGS_CFI) $(CFLAGS_WNAPM) $(CFLAGS_WNAB) \ - $(CFLAGS_NLTO) $(CFLAGS_MS_ABI) + $(CFLAGS_NLTO) $(CFLAGS_NAS) $(CFLAGS_MS_ABI) CFLAGS_i386 += $(call CFLAGS_COND,i386) CFLAGS_x86_64 += $(call CFLAGS_COND,x86_64) CFLAGS_arm64 += $(call CFLAGS_COND,arm64) diff --git a/src/byteswap.h b/src/byteswap.h index 8811ec3..f29112e 100644 --- a/src/byteswap.h +++ b/src/byteswap.h @@ -85,7 +85,7 @@ __bswap_64s ( uint64_t *x ) { static inline __attribute__ (( always_inline, const )) uint16_t __bswap_variable_16 ( uint16_t x ) { - __asm__ ( "rev16 %0, %1" : "=r" ( x ) : "r" ( x ) ); + __asm__ ( "rev16 %x0, %x1" : "=r" ( x ) : "r" ( x ) ); return x; } @@ -96,7 +96,7 @@ __bswap_16s ( uint16_t *x ) { static inline __attribute__ (( always_inline, const )) uint32_t __bswap_variable_32 ( uint32_t x ) { - __asm__ ( "rev32 %0, %1" : "=r" ( x ) : "r" ( x ) ); + __asm__ ( "rev32 %x0, %x1" : "=r" ( x ) : "r" ( x ) ); return x; } diff --git a/src/elf2efi.c b/src/elf2efi.c index 1eb3e28..21bc346 100644 --- a/src/elf2efi.c +++ b/src/elf2efi.c @@ -828,6 +828,8 @@ static void process_reloc ( struct elf_file *elf, const Elf_Shdr *shdr, case ELF_MREL ( EM_ARM, R_ARM_V4BX ): case ELF_MREL ( EM_X86_64, R_X86_64_PC32 ) : case ELF_MREL ( EM_X86_64, R_X86_64_PLT32 ) : + case ELF_MREL ( EM_X86_64, R_X86_64_GOTPCRELX ) : + case ELF_MREL ( EM_X86_64, R_X86_64_REX_GOTPCRELX ) : case ELF_MREL ( EM_AARCH64, R_AARCH64_CALL26 ) : case ELF_MREL ( EM_AARCH64, R_AARCH64_JUMP26 ) : case ELF_MREL ( EM_AARCH64, R_AARCH64_ADR_PREL_LO21 ) : @@ -837,6 +839,7 @@ static void process_reloc ( struct elf_file *elf, const Elf_Shdr *shdr, case ELF_MREL ( EM_AARCH64, R_AARCH64_LDST16_ABS_LO12_NC ) : case ELF_MREL ( EM_AARCH64, R_AARCH64_LDST32_ABS_LO12_NC ) : case ELF_MREL ( EM_AARCH64, R_AARCH64_LDST64_ABS_LO12_NC ) : + case ELF_MREL ( EM_AARCH64, R_AARCH64_LDST128_ABS_LO12_NC ) : case ELF_MREL ( EM_LOONGARCH, R_LARCH_B26): case ELF_MREL ( EM_LOONGARCH, R_LARCH_PCALA_HI20 ): case ELF_MREL ( EM_LOONGARCH, R_LARCH_PCALA_LO12 ): diff --git a/src/script.lds b/src/script.lds index 9dc8039..570b362 100644 --- a/src/script.lds +++ b/src/script.lds @@ -58,6 +58,8 @@ SECTIONS { *(.rodata.*) *(.data) *(.data.*) + *(.got) + *(.got.*) . = ALIGN ( alignment ); _edata = .; }