Skip to content

Commit

Permalink
WIP - clang
Browse files Browse the repository at this point in the history
  • Loading branch information
mcb30 committed Dec 6, 2023
1 parent 707bd4c commit ad6a994
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
14 changes: 12 additions & 2 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -102,6 +107,7 @@ ifneq ($(DEBUG),)
CFLAGS += -DDEBUG=$(DEBUG)
endif
CFLAGS += $(EXTRA_CFLAGS)
LDFLAGS += --no-relax

# Build flags for i386 target
#
Expand Down Expand Up @@ -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(); \
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/byteswap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
3 changes: 3 additions & 0 deletions src/elf2efi.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) :
Expand All @@ -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 ):
Expand Down
2 changes: 2 additions & 0 deletions src/script.lds
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ SECTIONS {
*(.rodata.*)
*(.data)
*(.data.*)
*(.got)
*(.got.*)
. = ALIGN ( alignment );
_edata = .;
}
Expand Down

0 comments on commit ad6a994

Please sign in to comment.