Skip to content

Commit c931d34

Browse files
olofjwildea01
authored andcommitted
arm64: build with baremetal linker target instead of Linux when available
Not all toolchains have the baremetal elf targets, RedHat/Fedora ones in particular. So, probe for whether it's available and use the previous (linux) targets if it isn't. Reported-by: Laura Abbott <labbott@redhat.com> Tested-by: Laura Abbott <labbott@redhat.com> Acked-by: Masahiro Yamada <yamada.masahiro@socionext.com> Cc: Paul Kocialkowski <contact@paulk.fr> Signed-off-by: Olof Johansson <olof@lixom.net> Signed-off-by: Will Deacon <will.deacon@arm.com>
1 parent 14d6e28 commit c931d34

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

arch/arm64/Makefile

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,16 @@ ifeq ($(CONFIG_CPU_BIG_ENDIAN), y)
6060
KBUILD_CPPFLAGS += -mbig-endian
6161
CHECKFLAGS += -D__AARCH64EB__
6262
AS += -EB
63-
LD += -EB
64-
LDFLAGS += -maarch64linuxb
63+
# Prefer the baremetal ELF build target, but not all toolchains include
64+
# it so fall back to the standard linux version if needed.
65+
LDFLAGS += -EB $(call ld-option, -maarch64elfb, -maarch64linuxb)
6566
UTS_MACHINE := aarch64_be
6667
else
6768
KBUILD_CPPFLAGS += -mlittle-endian
6869
CHECKFLAGS += -D__AARCH64EL__
6970
AS += -EL
70-
LD += -EL
71-
LDFLAGS += -maarch64linux
71+
# Same as above, prefer ELF but fall back to linux target if needed.
72+
LDFLAGS += -EL $(call ld-option, -maarch64elf, -maarch64linux)
7273
UTS_MACHINE := aarch64
7374
endif
7475

scripts/Kbuild.include

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ cc-ldoption = $(call try-run,\
163163
$(CC) $(1) $(KBUILD_CPPFLAGS) $(CC_OPTION_CFLAGS) -nostdlib -x c /dev/null -o "$$TMP",$(1),$(2))
164164

165165
# ld-option
166-
# Usage: LDFLAGS += $(call ld-option, -X)
167-
ld-option = $(call try-run, $(LD) $(LDFLAGS) $(1) -v,$(1),$(2))
166+
# Usage: LDFLAGS += $(call ld-option, -X, -Y)
167+
ld-option = $(call try-run, $(LD) $(LDFLAGS) $(1) -v,$(1),$(2),$(3))
168168

169169
# ar-option
170170
# Usage: KBUILD_ARFLAGS := $(call ar-option,D)

0 commit comments

Comments
 (0)