[U-Boot] [PATCH 2/4] Merge all mpc85xx platforms to use a single ld script

Trent Piepho tpiepho at freescale.com
Wed Oct 15 01:32:55 CEST 2008


On Tue, 14 Oct 2008, Wolfgang Denk wrote:
> In message <Pine.LNX.4.64.0810140859340.3443 at t2.domain.actdsltmp> you wrote:
>>
>> This is where bss goes when u-boot is linked.  It gets relocated to a
>> different address in ram.
>
> Where is defined which address it is, then?

It is determined at run time.  Look in cpu/mpc85xx/start.S at relocate_code.

But this has nothing to do with my patch.  I'm not touching those files or
changing how they work.

> Note that this added complexity of image layout is not shared by other
> architectures.

I suppose locating the reset vector at the bottom instead of the top makes
that easier.

>> What the linker scripts *were* doing is putting bss at ADDR(.text) + 0x80000,
>> which ends up being 0 for most boards and 0xf0000000 for some others.
>
> Let's be careful here in our terminology. Your "most boards" is  most
> probably  not  my "most boards". From the global point of view, "most
> boards" have a very simple layout like this:

My most boards is most 85xx boards.

>  __init_end = .;
>
>  __bss_start = .;
>  .bss (NOLOAD)      :
>
> BTW - this example is from a MPC85xx system...

This wastes space in the u-boot image.  bss is consuming address space between
the end of the data section and the boot page that it doesn't need to.

All the Freescale mpc85xx boards have been changed to no longer do this, since
this patch:

commit f0ff885ca64655bee6540eb8a25eed90b1152686
Author: Kumar Gala <galak at kernel.crashing.org>
Date:   Wed Jul 30 14:13:30 2008 -0500

     mpc85xx: Update linker scripts for Freescale boards

     * Move to using absolute addressing always.  Makes the scripts a bit more
       portable and common
     * Moved .bss after the end of the image.  These allows us to have more
       room in the resulting binary image for code and data.
....

It looks like you're looking at something like mpc8540eval, which could
probably benefit from this change as well if the maintainer of that board
feels like doing it.

BTW, if you continue to look at the mpc8540eval script, just past were you cut
it off, you'll see:
   . = (. & 0xFFF80000) + 0x0007F000;
   .bootpg   :

That 0xFFF80000 comes a flask bank size of 8MB!  If __flash_mask = 8M - 1,
then ~(__flash_mask) == 0xFFF80000.  So don't say I'm *adding* the flash bank
size to the linker script.  It's already there!  I'm just doing it in a better
way.

>> Unless you try to make a non 512K image.  Then bss might end up at 0x40000
>> when it should still be at 0.  You could hard code the address 0, there are
>
> The bss must NEVER, never ever be loated at 0.

Seems to be working fine since Jul 30th.  This is without my patchs applied,
though they don't make any difference.

$ make MPC8548CDS_config && make
$ grep ^.bss u-boot.map
.bss            0x00000000     0x69b8

OMFG, bss is at zero!  Fasten your seatbelts, 'cause we're all gonna crash!

>> The way I'm finding the location to link bss works for all mpc85xx system and
>> for all images sizes.  This lets them share the same linker script.
>
> Are you really talking about *all* MPC85xx systems, oronlyu about the
> FSL boards?

All the FSL boards, but all the other mpc85xx system could probably do it the
same way and use the same linker script that I've made the FSL boards use.

> And where is bss in your design at run-time, after relocation?

It's not "my" design.  The code's been there since before *I* ever looked at
it.  And I'm not changing this design either.

>>> Have you actually tested this code?  Didn't you run into such problems?
>>
>> The resulting u-boot binary is exactly the same.  This produces the same
>> binaries as before using one linker script for all 85xx instead of a different
>> one for each board.
>
> Please define "all 85xx". I tend to doubt that.

How about this, ALL boards.  Every single last one of them.  Either my patches
don't touch them or they use the new common linker script and get linked in
the same way they were before.  Go ahead and try applying my first two patches
and do a before and after comparison on the u-boot.map file.  It's nothing but
cosmetic changes, all the code is at the same place.

$ make MPC8548CDS_config && make
$ cp u-boot.map u-boot.map.old
$ stg push abs-boot && stg push mpc85xx-single-ld-script
$ make clean && make
$ diff -u u-boot.map.old u-boot.map
--- u-boot.map.old      2008-10-14 16:13:59.000000000 -0700
+++ u-boot.map  2008-10-14 16:15:38.000000000 -0700
@@ -1735,19 +1735,19 @@
   *(.data.init)
                  0xfffb3c00                . = ALIGN (0x100)
                  0xfffb3c00                __init_end = .
+                0x003fffff                PROVIDE (__flash_mask, 0x3fffff)

  .bootpg         0xfffff000      0x1cc
- cpu/mpc85xx/start.o(.bootpg)
+ *(.bootpg)
   .bootpg        0xfffff000      0x1cc cpu/mpc85xx/start.o
                  0xfffff000                _start_e500

  .resetvec       0xfffffffc        0x4
   *(.resetvec)
   .resetvec      0xfffffffc        0x4 cpu/mpc85xx/resetvec.o
-                0x00000000                . = (ADDR (.text) + 0x80000)
-                0x00000000                __bss_start = .

  .bss            0x00000000     0x69b8
+                0x00000000                __bss_start = <code 345> (.)
   *(.sbss)
   .sbss          0x00000000        0x0 cpu/mpc85xx/start.o
   .sbss          0x00000000        0x8 cpu/mpc85xx/libmpc85xx.a(traps.o)

It's nothing but cosmetic differences.  All the objects have the same size and
same location as they did pre-patch.


More information about the U-Boot mailing list