[U-Boot-Users] [PPC] PLEASE READ - was: [PATCH] Fix linker scripts: add NOLOAD atribute to .bss/.sbss sections

Wolfgang Denk wd at denx.de
Mon Feb 4 00:32:36 CET 2008


Dear Stefan,

in message <200801131459.19164.sr at denx.de> you wrote:
>
> Thanks. This fixes overlapping problems with bss as seen on Ocotea with
> ELDK 4.2. But unfortunately I still have other overlapping problems for
> example on Katmai with ELDK 4.2:
...
> ppc_4xx-ld: u-boot: section .bootpg lma 0xfffff000 overlaps previous sections
> ppc_4xx-ld: u-boot: section .data.rel.ro lma 0xfffff3f8 overlaps previous sections
> ppc_4xx-ld: u-boot: section .u_boot_cmd lma 0xfffff408 overlaps previous sections
> make: *** [u-boot] Error 1

This problem comes from the fact that the code has become larger when
using GCC 4.2.x; this is somewhat a surprise as we  all  expect  more
recent versions of the compiler to provide better optimization.

Please see this thread for discussion of the problem:
http://gcc.gnu.org/ml/gcc/2008-01/msg00228.html

Basicly, it comes down to this explanation:

| GCC does not use the load and store multiple instructions because the source
| file declares r29 a global variable:
| 
| register volatile gd_t *gd asm ("r29");
| 
| The bug fix mentioned above inhibits GCC from using lmw/stmw if global
| registers are present in the contiguous register sequence because GCC
| incorrectly would overwrite the register.  If the register variable declaration
| is removed, GCC uses the lmw/stmw instructions.  r29 is a bad choice for a
| global register variable.

So far, it is not clear to me what  a  better  choice  for  a  global
register variable could be (i. e. which register we can chose for our
purpose without causing the same or other problems.

A possible approach to this  problem  is  to  avoid  using  a  global
register  variable  and  use  a  plain  global  variable instead. The
necessary code for this is already there (just commented out); when I
implemented this initially,  I  decided  to  use  a  global  register
variable because it gave slightly smaller code.

Here is an overview of the effect (test build of current top of  tree
for the "katmai" (PPC440SPe) board):

ELDK Version	Register-Var.			Globale Var.
	   text    data     bss     dec	      text    data     bss     dec
4.0	 243292   13700  322340  579332	    244160   13808  322340  580308
4.1	 243292   13700  322340  579332     244160   13808  322340  580308
4.2	 section ... overlaps previous	    245496   13188  322340  581024

As you can see, the difference in code size is less than 1 KiB.


My suggestion is to change the code to use a plain  global  variable,
however  I  need  feedback  if we can / want to do that as it effects
*ALL* PowerPC boards.


Please comment.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Accident: A condition in which presence of mind is good, but  absence
of body is better.




More information about the U-Boot mailing list