Commit 6ac9f47977a9fc1876979871eeb14f26ba1bdbe6

Authored by Mike Frysinger
Committed by Wolfgang Denk
1 parent 2ed0869d30

start a linker script helper file

Start a common header file for common linker script code (such as
workarounds for older linkers) rather than doing this in the build system.

As fallout, we no longer execute the linker every time config.mk is
included by a build file (which can easily be 70+ times), but rather only
execute it once.

This also fixes a bug in the major version checking by creating a macro to
easily compare versions and keep people from making the same common
mistake (forgetting to check major and minor together).

Signed-off-by: Mike Frysinger <vapier@gentoo.org>

Showing 3 changed files with 33 additions and 10 deletions Side-by-side Diff

... ... @@ -267,6 +267,14 @@
267 267 PLATFORM_LIBS += $(PLATFORM_LIBGCC)
268 268 export PLATFORM_LIBS
269 269  
  270 +# Special flags for CPP when processing the linker script.
  271 +# Pass the version down so we can handle backwards compatibility
  272 +# on the fly.
  273 +LDPPFLAGS += \
  274 + -include $(TOPDIR)/include/u-boot/u-boot.lds.h \
  275 + $(shell $(LD) --version | \
  276 + sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\).*/-DLD_MAJOR=\1 -DLD_MINOR=\2/p')
  277 +
270 278 ifeq ($(CONFIG_NAND_U_BOOT),y)
271 279 NAND_SPL = nand_spl
272 280 U_BOOT_NAND = $(obj)u-boot-nand.bin
... ... @@ -171,16 +171,6 @@
171 171 LDFLAGS += -Ttext $(TEXT_BASE)
172 172 endif
173 173  
174   -# Special flags for CPP when processing the linker script
175   -# Linker versions prior to 2.16 don't understand the builting
176   -# functions SORT_BY_ALIGNMENT() and SORT_BY_NAME(), so disable these
177   -ifeq ($(shell $(LD) -v | \
178   - sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\) .*/[ \1 -lt 2 ] || [ \2 -lt 16 ] \&\& echo old_ld/p' | \
179   - sh),old_ld)
180   -LDPPFLAGS += -D'SORT_BY_ALIGNMENT(x)=x' -D'SORT_BY_NAME(x)=x'
181   -endif
182   -
183   -
184 174 # Location of a usable BFD library, where we define "usable" as
185 175 # "built for ${HOST}, supports ${TARGET}". Sensible values are
186 176 # - When cross-compiling: the root of the cross-environment
include/u-boot/u-boot.lds.h
  1 +/*
  2 + * Linker script helper macros
  3 + *
  4 + * Copyright (c) 2009 Analog Devices Inc.
  5 + *
  6 + * Licensed under the GPL-2 or later.
  7 + */
  8 +
  9 +#ifndef __U_BOOT_LDS__
  10 +#define __U_BOOT_LDS__
  11 +
  12 +/* See if the linker version is at least the specified version */
  13 +#define LD_AT_LEAST(major, minor) \
  14 + ((major > LD_MAJOR) || (major == LD_MAJOR && minor <= LD_MINOR))
  15 +
  16 +/*
  17 + * Linker versions prior to 2.16 don't understand the builtin
  18 + * functions SORT_BY_ALIGNMENT() and SORT_BY_NAME(), so disable these
  19 + */
  20 +#if !LD_AT_LEAST(2, 16)
  21 +# define SORT_BY_ALIGNMENT(x) x
  22 +# define SORT_BY_NAME(x) x
  23 +#endif
  24 +
  25 +#endif