Use GCC instead of LD to trigger the linker

Invoke the linker through gcc rather than directly with ld.
This will allow us to use some more advanced features : e.g. LTO.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BUG=none
BRANCH=none
TEST=make buildall
then compare manually old and new binaries

Change-Id: I101b1edbaebd5628624a5a8c12d5c0b5fa9e2c50
Reviewed-on: https://chromium-review.googlesource.com/271290
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Trybot-Ready: Vincent Palatin <vpalatin@chromium.org>
This commit is contained in:
Vincent Palatin
2015-05-01 15:57:22 -07:00
committed by ChromeOS Commit Bot
parent 91b9c336ee
commit 24f4e36d82
2 changed files with 7 additions and 7 deletions

View File

@@ -45,7 +45,7 @@ cmd_elf_to_dis = $(OBJDUMP) -D $< > $@
cmd_elf_to_hex = $(OBJCOPY) -O ihex $< $@
cmd_bin_to_hex = $(OBJCOPY) -I binary -O ihex \
--change-addresses $(_flash_base) $^ $@
cmd_elf = $(LD) $(objs) $(LDFLAGS) -o $@ -T $< -Map $(out)/$*.map
cmd_elf = $(CC) $(objs) $(LDFLAGS) -o $@ -Wl,-T,$< -Wl,-Map,$(out)/$*.map
cmd_smap = $(NM) $< | sort > $@
cmd_exe = $(CC) $(objs) $(HOST_TEST_LDFLAGS) -o $@
cmd_c_to_o = $(CC) $(CFLAGS) -MMD -MF $@.d -c $< -o $@
@@ -251,9 +251,9 @@ $(npcx-flash-fw-bin):
-@ mkdir -p $(@D)
-@ $(CC) $(CFLAGS) -MMD -MF $(out)/$(npcx-lfw).d -c $(npcx-flash-fw).c \
-o $(out)/$(npcx-flash-fw).o
-@ $(LD) $(out)/$(npcx-flash-fw).o $(LDFLAGS) \
-o $(out)/$(npcx-flash-fw).elf -T $(npcx-flash-fw).ld \
-Map $(out)/$(npcx-flash-fw).map
-@ $(CC) $(out)/$(npcx-flash-fw).o $(LDFLAGS) \
-o $(out)/$(npcx-flash-fw).elf -Wl,-T,$(npcx-flash-fw).ld \
-Wl,-Map,$(out)/$(npcx-flash-fw).map
-@ $(OBJCOPY) -O binary $(out)/$(npcx-flash-fw).elf $@
# TODO: optional make rules for PROJECT_EXTRA
@@ -262,8 +262,8 @@ $(npcx-lfw-bin):
-@ mkdir -p $(@D)
-@ $(CC) $(CFLAGS) -MMD -MF $(out)/$(npcx-lfw).d -c $(npcx-lfw).c \
-o $(out)/$(npcx-lfw).o
-@ $(LD) $(out)/$(npcx-lfw).o $(LDFLAGS) -o $(out)/$(npcx-lfw).elf \
-T $(npcx-lfw).ld -Map $(out)/$(npcx-lfw).map
-@ $(CC) $(out)/$(npcx-lfw).o $(LDFLAGS) -o $(out)/$(npcx-lfw).elf \
-Wl,-T,$(npcx-lfw).ld -Wl,-Map,$(out)/$(npcx-lfw).map
-@ $(OBJCOPY) -O binary $(out)/$(npcx-lfw).elf $@
.PHONY: xrefs

View File

@@ -55,7 +55,7 @@ LIBFTDI_LDLIBS=$(shell $(PKG_CONFIG) --libs lib${LIBFTDI_NAME})
BUILD_CFLAGS= $(LIBFTDI_CFLAGS) $(CPPFLAGS) -O3 $(CFLAGS_DEBUG) $(CFLAGS_WARN)
HOST_CFLAGS=$(CPPFLAGS) -O3 $(CFLAGS_DEBUG) $(CFLAGS_WARN) -DHOST_TOOLS_BUILD
LDFLAGS=-nostdlib -X --gc-sections
LDFLAGS=-nostdlib -Wl,-X -Wl,--gc-sections -Wl,--build-id=none
BUILD_LDFLAGS=$(LIBFTDI_LDLIBS)
HOST_TEST_LDFLAGS=-T core/host/host_exe.lds -lrt -pthread -rdynamic -lm\
$(if $(TEST_COVERAGE),-fprofile-arcs,)