[Skiboot] [PATCH v2 07/11] Makefile: Use LD to link the final binary

Joel Stanley joel at jms.id.au
Fri May 4 12:10:32 AEST 2018


We were using gcc instead of ld. This isn't required, as we're disabling
all of the things that gcc could do for us.

This helps enable clang as the compiler, with GNU ld used for the
final linking step.

Signed-off-by: Joel Stanley <joel at jms.id.au>
---
 Makefile.main | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/Makefile.main b/Makefile.main
index 8cd5e2d1ed4d..92dd92b826b1 100644
--- a/Makefile.main
+++ b/Makefile.main
@@ -128,7 +128,8 @@ LDFLAGS += -Wl,-pie
 LDFLAGS += -Wl,-Ttext-segment,$(LD_TEXT) -Wl,-N -Wl,--build-id=none
 LDFLAGS += -Wl,--no-multi-toc
 LDFLAGS += -mcpu=power7 -mbig-endian -Wl,--oformat,elf64-powerpc
-LDFLAGS_FINAL = $(LDFLAGS) -Wl,--whole-archive
+LDFLAGS_FINAL = -EB -m elf64ppc --no-multi-toc -N --build-id=none --whole-archive
+LDFLAGS_FINAL += -static -nostdlib -pie -Ttext-segment=$(LD_TEXT) --oformat=elf64-powerpc
 LDRFLAGS=-melf64ppc
 # Debug stuff
 #LDFLAGS += -Wl,-v -Wl,-Map,foomap 
@@ -267,12 +268,12 @@ $(TARGET).tmp.a: $(ALL_OBJS)
 	$(call Q,AR, $(AR) rcsTPD $@ $(ALL_OBJS), $@)
 
 $(TARGET).tmp.elf: $(ALL_OBJS_1) $(TARGET).lds $(KERNEL)
-	$(call Q,LD, $(CC) $(LDFLAGS_FINAL) -o $@ -T $(TARGET).lds $(ALL_OBJS_1), $@)
+	$(call Q,LD, $(LD) $(LDFLAGS_FINAL) -o $@ -T $(TARGET).lds $(ALL_OBJS_1), $@)
 
 asm/real_map.o : $(TARGET).tmp.map
 
 $(TARGET).elf: $(ALL_OBJS_2) $(TARGET).lds $(KERNEL)
-	$(call Q,LD, $(CC) $(LDFLAGS_FINAL) -o $@ -T $(TARGET).lds $(ALL_OBJS_2), $@)
+	$(call Q,LD, $(LD) $(LDFLAGS_FINAL) -o $@ -T $(TARGET).lds $(ALL_OBJS_2), $@)
 
 $(SUBDIRS):
 	$(call Q,MKDIR,mkdir -p $@, $@)
-- 
2.17.0



More information about the Skiboot mailing list