[U-Boot] [PATCH] Fix all linker scripts for older binutils versions (pre-2.16)

Mike Frysinger vapier at gentoo.org
Sun Aug 23 08:09:09 CEST 2009


On Sunday 23 August 2009 01:34:38 Wolfgang Denk wrote:
> Mike Frysinger wrote:
> > On Monday 17 August 2009 08:00:53 Wolfgang Denk wrote:
> > > --- a/config.mk
> > > +++ b/config.mk
> > > @@ -166,11 +166,21 @@ endif
> > > +# Special flags for CPP when processing the linker script
> > > +# Linker versions prior to 2.16 don't understand the builting
> > > +# functions SORT_BY_ALIGNMENT() and SORT_BY_NAME(), so disable these
> > > +ifeq ($(shell $(LD) -v | \
> > > +	sed -ne 's/GNU ld version \([0-9][0-9]*\)\.\([0-9][0-9]*\) .*/[ \1
> > > -lt 2 ] || [ \2 -lt 16 ] \&\& echo old_ld/p' | \ +	sh),old_ld)
> > > +LDPPFLAGS +=3D -D'SORT_BY_ALIGNMENT(x)=3Dx' -D'SORT_BY_NAME(x)=3Dx'
> > > +endif
> >
> > this check will fail with binutils 3.0+ because of the minor check for 16
> > without a corresponding major check.
>
> Well, the "\1 -lt 2" is the major check, isn't it?

here is how the shell code looks:
[ $major -lt 2 ] || [ $minor -lt 16 ] && echo old_ld

and the way shell logic works, the echo is executed if either of those tests 
fail.  what you really wanted was:
[ $major -lt 2 ] || [ $major -eq 2 -a $minor -lt 16 ] && echo old_ld

fairly common bug that comes up when people try processing tool versions on a 
major.minor.micro basis

but this is largely irrelevant if we move the logic from the build system to 
the header file as this will (should) get fixed in the process

> > the way it's written now causes ld to get executed every time config.mk
> > is included.  my current test shows that is like 80 times, or 79 useless
> > runs. even if we make this a bit smarter (saving the output in a var and
> > exporting it), that cuts things down to like 60 executions.  considering
> > this test is only used by the linker script code, why not keep it in the
> > top-level Makefile.
>
> Patches welcome...

i wanted to make sure we were on the same page before sending patches
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
Url : http://lists.denx.de/pipermail/u-boot/attachments/20090823/82efd88f/attachment.pgp 


More information about the U-Boot mailing list