From 1aada9cd643567d351667138851e9231ccfa245a Mon Sep 17 00:00:00 2001 From: Wolfgang Denk Date: Mon, 17 Aug 2009 14:00:53 +0200 Subject: Fix all linker scripts for older binutils versions (pre-2.16) Commit f62fb99941c6 fixed handling of all rodata sections by using a wildcard combined with calls to ld's builtin functions SORT_BY_ALIGNMENT() and SORT_BY_NAME(). Unfortunately these functions were only introduced with biunutils version 2.16, so the modification broke building with all tool chains using older binutils. This patch makes it work again. This is done by omitting the use of these functions for such old tool chains. This will result in slightly larger target binaries, as the rodata sections are no longer in optimal order alignment-wise which reauls in unused gaps, but the effect was found to be insignificant - especially compared to the fact that you cannot build U-Boot at all in the current state. As ld seems to have no support for conditionals we run the linker script through the C preprocessor which can be easily used to remove the unwanted function calls. Note that the C preprocessor must be run with the "-ansi" (or a "-std=") option to make sure all the system-specific predefined macros outside the reserved namespace are suppressed. Otherise, cpp might for example substitute "powerpc" to "1", thus corrupting for example "OUTPUT_ARCH(powerpc)" etc. Signed-off-by: Wolfgang Denk Cc: Mike Frysinger --- board/netstar/Makefile | 9 ++++++--- board/voiceblue/Makefile | 11 +++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) (limited to 'board') diff --git a/board/netstar/Makefile b/board/netstar/Makefile index 8f35f93..11578b7 100644 --- a/board/netstar/Makefile +++ b/board/netstar/Makefile @@ -50,8 +50,8 @@ all: $(obj).depend $(LIB) $(obj)eeprom.srec $(obj)eeprom.bin \ $(LIB): $(OBJS) $(SOBJS) $(AR) $(ARFLAGS) $@ $^ -$(obj)eeprom.srec: $(obj)eeprom.o $(obj)eeprom_start.o - cd $(lnk) && $(LD) -T $(LDSCRIPT) -g -Ttext $(LOAD_ADDR) \ +$(obj)eeprom.srec: $(obj)eeprom.o $(obj)eeprom_start.o $(obj)u-boot.lds + cd $(lnk) && $(LD) -T $(obj)u-boot.lds -g -Ttext $(LOAD_ADDR) \ -o $(<:.o=) -e eeprom eeprom.o eeprom_start.o \ -L$(obj)../../examples/standalone -lstubs \ -L$(obj)../../lib_generic -lgeneric \ @@ -78,10 +78,13 @@ $(obj)crcit.o: crcit.c $(obj)crc32.o: $(SRCTREE)/lib_generic/crc32.c $(HOSTCC) $(HOSTCFLAGS) -DUSE_HOSTCC -o $@ -c $< +$(obj)u-boot.lds: $(LDSCRIPT) + $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@ + clean: rm -f $(SOBJS) $(OBJS) $(obj)eeprom $(obj)eeprom.srec \ $(obj)eeprom.bin $(obj)crcek $(obj)crcek.srec \ - $(obj)crcek.bin + $(obj)crcek.bin $(obj)u-boot.lds distclean: clean rm -f $(LIB) core *.bak $(obj).depend diff --git a/board/voiceblue/Makefile b/board/voiceblue/Makefile index 7bb92a6..121c717 100644 --- a/board/voiceblue/Makefile +++ b/board/voiceblue/Makefile @@ -44,8 +44,8 @@ all: $(obj).depend $(LIB) $(obj)eeprom.srec $(obj)eeprom.bin $(LIB): $(OBJS) $(SOBJS) $(AR) $(ARFLAGS) $@ $(OBJS) $(SOBJS) -$(obj)eeprom.srec: $(obj)eeprom.o $(obj)eeprom_start.o - cd $(lnk) && $(LD) -T $(LDSCRIPT) -g -Ttext $(LOAD_ADDR) \ +$(obj)eeprom.srec: $(obj)eeprom.o $(obj)eeprom_start.o $(obj)u-boot.lds + cd $(lnk) && $(LD) -T $(obj)u-boot.lds -g -Ttext $(LOAD_ADDR) \ -o $(<:.o=) -e eeprom eeprom.o eeprom_start.o \ -L$(obj)../../examples/standalone -lstubs \ -L$(obj)../../lib_generic -lgeneric \ @@ -55,11 +55,14 @@ $(obj)eeprom.srec: $(obj)eeprom.o $(obj)eeprom_start.o $(obj)eeprom.bin: $(obj)eeprom.srec $(OBJCOPY) -I srec -O binary $< $@ 2>/dev/null +$(obj)u-boot.lds: $(LDSCRIPT) + $(CPP) $(CPPFLAGS) $(LDPPFLAGS) -ansi -D__ASSEMBLY__ -P - <$^ >$@ + clean: rm -f $(SOBJS) $(OBJS) $(obj)eeprom \ $(obj)eeprom.srec $(obj)eeprom.bin \ - $(obj)eeprom.o $(obj)eeprom_start.o - + $(obj)eeprom.o $(obj)eeprom_start.o \ + $(obj)u-boot.lds distclean: clean rm -f $(LIB) core *.bak $(obj).depend -- cgit v1.1