possible issue with bss section in sparc

Stephan Gruenfelder stephan.gruenfelder at space.at
Wed Aug 29 08:26:27 UTC 2007


Hi Aleix,

if "std" accesses data, which is not 8-bytes aligned, the SPARC processor would 
trap (i.e. stop operating in most conditions). It that is your "weird" behaviour 
than your observation makes sense.

Regards
Stephan

Aleix Conchillo Flaqué wrote:
> Hi all,
> 
> yesterday I changed some dynamic allocated arrays of structures to
> static arrays and the application I am working on had a really weird
> behaviour. I changed the array to dynamic and everything worked
> properly again. So, after a couple of hours I started thinking that it
> could be a problem of the bss section (a moment of desperation I
> guess).
> 
> I had a look at the linker script
> (c/src/lib/libbsp/sparc/erc32/startup/linkcmds):
> 
>   .bss :
>   {
>     __bss_start = ALIGN(0x8);
>     _bss_start = .;
>     bss_start = .;
>     *(.bss)
>     *(COMMON)
>     end = .;
>     _end = ALIGN(0x8);
>     __end = ALIGN(0x8);
>   } > ram
> 
> And at the startup code (c/src/lib/libbsp/sparc/shared/start.S):
> 
>         /* clear the bss */
> 1:
> 
>         sethi %hi(_edata),%g2
>         or    %g2,%lo(_edata),%g2       ! g2 = start of bss
>         sethi %hi(_end),%g3
>         or    %g3,%lo(_end),%g3         ! g3 = end of bss
>         mov   %g0,%g1                   ! so std has two zeros
> zerobss:
>         std    %g0,[%g2]
>         add    %g2,8,%g2
>         cmp    %g2,%g3
>         bleu,a zerobss
>         nop
> 
> And I thought it could be a problem on the alignment of the bss
> section, which aligns to the next byte, and the instruction "std
> %g0,[%g2]" which stores 8 bytes at the same time. I'm not an expert on
> this, so this was another moment of desperation.
> 
> I tried out two separate things: first, change the alignment to
> ALIGN(16), and second, change the assembly to (keeping ALIGN(8)):
> 
>         stb    %g0,[%g2]
>         add    %g2,1,%g2
> 
> Both things worked well. So, I'm wondering if that makes any sense at
> all. Could it be that the "std" is overwriting some bytes that it
> should not? Should I find the error in my application, probably a
> memory issue, because the bss thing doesn't make any sense?
> 
> Any clues would be really appreciated.
> 
> Thanks in advance,
> 
> Aleix
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.com
> http://rtems.rtems.org/mailman/listinfo/rtems-users
> 

-- 
====================================================
Stephan GRUENFELDER
Dr.techn., Software Engineer

Tel.  : +43-1-80199/5530
Fax   : +43-1-80199/5577
E-Mail: stephan.gruenfelder at space.at
AUSTRIAN AEROSPACE GmbH
Stachegasse 16
A-1120 Vienna, AUSTRIA / EUROPE
FN 91260 g Handelsgericht Wien
www.space.at


This e-mail is for information only. Any contractual obligations require a confirmation by a company fax or letter.
This e-mail and any file attached to it may contain confidential information. If you are not the intended recipient, please delete this e-mail from your system immediately and notify us of the erroneous transmission; any other use of this e-mail is prohibited.




More information about the users mailing list