@@ -433,13 +433,15 @@ ELFFLAGS += -Wl,--no-dynamic-linker -Wl,-pie
ELFFLAGS += $(platform-ldflags-y)
ELFFLAGS += $(firmware-ldflags-y)
+MERGEFLAGS += $(USE_LD_FLAG)
+MERGEFLAGS += -nostdlib
MERGEFLAGS += -r
ifeq ($(LD_IS_LLD),y)
-MERGEFLAGS += -b elf
+MERGEFLAGS += -Wl,-b,elf
else
-MERGEFLAGS += -b elf$(PLATFORM_RISCV_XLEN)-littleriscv
+MERGEFLAGS += -Wl,-b,elf$(PLATFORM_RISCV_XLEN)-littleriscv
endif
-MERGEFLAGS += -m elf$(PLATFORM_RISCV_XLEN)lriscv
+MERGEFLAGS += -Wl,-m,elf$(PLATFORM_RISCV_XLEN)lriscv
DTSCPPFLAGS = $(CPPFLAGS) -nostdinc -nostdlib -fno-builtin -D__DTS__ -x assembler-with-cpp
@@ -459,7 +461,7 @@ define dynamic_flags
endef
merge_objs = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
echo " MERGE $(subst $(build_dir)/,,$(1))"; \
- $(LD) $(MERGEFLAGS) $(2) -o $(1)
+ $(CC) $(MERGEFLAGS) $(2) -o $(1)
merge_deps = $(CMD_PREFIX)mkdir -p `dirname $(1)`; \
echo " MERGE-DEP $(subst $(build_dir)/,,$(1))"; \
cat $(2) > $(1)
On some platforms, the default linker is `mold`, which can cause the following error. Adding the `--fuse-ld` option can prevent this problem. MERGE platform/generic/firmware/payloads/test.o mold: fatal: unknown command line option: -b elf64-littleriscv Signed-off-by: Xiang W <wangxiang@iscas.ac.cn> --- v2 changes: - s/-no-pie -Wl,-r/-r/ Makefile | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)