Skip to content
Snippets Groups Projects
Commit c22b8a56 authored by Alessandro Rubini's avatar Alessandro Rubini
Browse files

Makefile: build an intermediate object


Pretty often it happens that during trials we pick wrong external
functions (e.g., "printf") and the final link claims horribly about
dozens of undefined symbols.  By having an intermediate wrc.o we can
easily check which are the symbols we really leave undefined for libc
and libgcc to fill, before they resolve them by asking for something
else.

Signed-off-by: default avatarAlessandro Rubini <rubini@gnudd.com>
parent 2c128a1f
No related merge requests found
......@@ -7,6 +7,7 @@ BOARD = spec
CROSS_COMPILE ?= lm32-elf-
CC = $(CROSS_COMPILE)gcc
LD = $(CROSS_COMPILE)ld
OBJDUMP = $(CROSS_COMPILE)objdump
OBJCOPY = $(CROSS_COMPILE)objcopy
SIZE = $(CROSS_COMPILE)size
......@@ -93,12 +94,15 @@ all: tools $(OUTPUT).ram $(OUTPUT).vhd
.PRECIOUS: %.elf %.bin
.PHONY: all tools clean gitmodules
$(OUTPUT).elf: $(LDS) silentoldconfig gitmodules $(OBJS)
$(OUTPUT).elf: $(LDS) silentoldconfig gitmodules $(OUTPUT).o
$(CC) $(CFLAGS) -DGIT_REVISION=\"$(REVISION)\" -c revision.c
${CC} -o $@ revision.o $(OBJS) $(LDFLAGS)
${CC} -o $@ revision.o $(OUTPUT).o $(LDFLAGS)
${OBJDUMP} -d $(OUTPUT).elf > $(OUTPUT)_disasm.S
$(SIZE) $@
$(OUTPUT).o: $(OBJS)
$(LD) --gc-sections -e _start -r $(OBJS) -o $@
%.bin: %.elf
${OBJCOPY} -O binary $^ $@
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment