ar71xx: fix build of lzma-loader with binutils 2.25.1
[openwrt/staging/chunkeey.git] / target / linux / ar71xx / image / lzma-loader / src / Makefile
index 3e6839c7c3899d0283a3879af6e998abe99970d0..5f10bdb8f1499f24f00a8bf4d53f370fef88bd1e 100644 (file)
@@ -27,7 +27,8 @@ LD            := $(CROSS_COMPILE)ld
 OBJCOPY                := $(CROSS_COMPILE)objcopy
 OBJDUMP                := $(CROSS_COMPILE)objdump
 
-BIN_FLAGS      := -O binary -R .reginfo -R .note -R .comment -R .mdebug -S
+BIN_FLAGS      := -O binary -R .reginfo -R .note -R .comment -R .mdebug \
+                  -R .MIPS.abiflags -S
 
 CFLAGS         = -D__KERNEL__ -Wall -Wstrict-prototypes -Wno-trigraphs -Os \
                  -fno-strict-aliasing -fno-common -fomit-frame-pointer -G 0 \
@@ -68,7 +69,7 @@ ifneq ($(BOARD_DEF),)
 CFLAGS         += -DCONFIG_BOARD_$(BOARD_DEF)
 endif
 
-all: loader.bin
+all: loader.elf
 
 # Don't build dependencies, this may die if $(CC) isn't gcc
 dep:
@@ -84,16 +85,22 @@ install:
 data.o: $(LOADER_DATA)
        $(LD) -r -b binary --oformat $(O_FORMAT) -T lzma-data.lds -o $@ $<
 
-loader.bin: loader.elf
+loader: $(OBJECTS)
+       $(LD) $(LDFLAGS) -o $@ $(OBJECTS)
+
+loader.bin: loader
        $(OBJCOPY) $(BIN_FLAGS) $< $@
 
-loader.elf: $(OBJECTS)
-       $(LD) $(LDFLAGS) -o $@ $(OBJECTS)
+loader2.o: loader.bin
+       $(LD) -r -b binary --oformat $(O_FORMAT) -o $@ $<
+
+loader.elf: loader2.o
+       $(LD) -e startup -T loader2.lds -Ttext $(LOADADDR) -o $@ $<
 
 mrproper: clean
 
 clean:
-       rm -f *.elf *.bin *.o
+       rm -f loader *.elf *.bin *.o