This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
PowerPC no small data build uses .sbss? (but sbss should not be used,right?)
- From: "William. Rivet" <William dot Rivet at hs dot utc dot com>
- To: binutils at sources dot redhat dot com
- Date: Tue, 07 Jun 2005 09:40:49 -0400
- Subject: PowerPC no small data build uses .sbss? (but sbss should not be used,right?)
I have been trying to guarantee the lack of small data use in part of a
project I am working on (a minimal OS type product that itself will
leave small data registers for use by the application).
By using the gcc -mno-sdata it seems the code in fact does not use the
small data registers, and upon inspection of the assembler listing file,
it appears data is marked as ".comm zz1, 1, 4" for one example, and
".comm zz3,300,4" for another.
So at the assembly level, there appears to be no distinction for small
data....looking at the map file, I find zz1 is mapped to the .sbss
section and zz3 is mapped to the COMMON section.
I really would like to avoid explaining to our regulating body why we
have a small-bss section in our mapfile....is there a way to really
prevent .sbss sections from being generated? (the small initialized data
correctly goes into the .data section, not .sdata, so I don't show that
in my example)
I tried the ld "-d" option and the linker script
FORCE_COMMON_ALLOCATION, but no luck. I have run out of ideas.
Any help is appreciated, even if only to point out that this is indeed a
probable bug and the best I can get with the current GNU toolchains.
Thanks in advance,
Bill
-----------------------
I'm using powerpc-eabi-elf-gcc version 3.4.3, powerpc-eabi-elf-as and
powerpc-eabi-elf-ld version 2.16.
COMMON 0x40000004 0x12c fred.o
0x40000004 zz3 <--------------this is
what I want
.sdata 0x00000000 0x0 load address 0xc0100010
.sbss 0x00000000 0x8 load address 0xc0100010
.sbss 0x00000000 0x7 fred.o
0x00000000 zz1 <------
0x00000004 zz2 <------ These I didn't
expect...
0x00000006 yy <------ Can they be moved
to .bss?
.sbss 0x00000007 0x1 joe.o <----
0x00000007 x <--------
Here is my test sample code that shows the problem I am trying to solve.:
----------------------------------fred.c--------------
extern char x;
char yy;
char zz1[1];
char zz2[2];
char zz3[300];
char zzz1[1]=
{
1
}
;
int Fred(void){
return x;
}
----------------------------------------------------------------------
----joe.c (just to provide missing bits so link will pass---------
char x;
_start(){} /* don't care...only satisfying linker */
----------------------------------------------------------------------
-------------------sample.ld----------------------------------------
FORCE_COMMON_ALLOCATION
MEMORY
{
unmapped_sections_detector (rwxi) :
org = 0x00000000, len = 0x0
aprom (rx): org = 0x00100000, len = 0x40000
apram (wx): org = 0x40000000, len = 0xD000
}
SECTIONS
{
.aptext :
{
__text_start = .;
*(.text) *(.rodata*) *(.rdata) *(.init) *(.fini)
__text_end = .;
}>aprom
.apdata : AT ( ADDR(.aptext)+SIZEOF(.aptext) )
{
__data_start = .;
*(.data)
__data_end = .;
*(.bss) *(.osunused) *(COMMON) *(.comm)
} >apram
}
----------------------------------------------------------------------
-------------------sample.map----------------------------------------
Allocating common symbols
Common symbol size file
x 0x1 joe.o
zz1 0x1 fred.o
zz2 0x2 fred.o
yy 0x1 fred.o
zz3 0x12c fred.o
Memory Configuration
Name Origin Length Attributes
unmapped_sections_detector 0x00000000 0x00000000 xrwl
aprom 0x00100000 0x00040000 xr
apram 0x40000000 0x0000d000 xw
*default* 0x00000000 0xffffffff
Linker script and memory map
LOAD fred.o
LOAD joe.o
.aptext 0x00100000 0x10
0x00100000 __text_start = .
*(.text)
.text 0x00100000 0xc fred.o
0x00100000 Fred
.text 0x0010000c 0x4 joe.o
0x0010000c _start
*(.rodata*)
*(.rdata)
*(.init)
*(.fini)
0x00100010 __text_end = .
.sdata2 0x00000000 0x0
.apdata 0x40000000 0x130 load address 0x00100010
0x40000000 __data_start = .
*(.data)
.data 0x40000000 0x4 fred.o
0x40000000 zzz1
0x40000004 __data_end = .
*(.bss)
*(.osunused)
*(COMMON)
COMMON 0x40000004 0x12c fred.o
0x40000004 zz3
*(.comm)
.sdata 0x00000000 0x0 load address 0xc0100010
.sbss 0x00000000 0x8 load address 0xc0100010
.sbss 0x00000000 0x7 fred.o
0x00000000 zz1
0x00000004 zz2
0x00000006 yy
.sbss 0x00000007 0x1 joe.o
0x00000007 x
.rela.dyn
OUTPUT(startfiles elf32-powerpc)
.comment 0x00000000 0x24
.comment 0x00000000 0x12 fred.o
.comment 0x00000012 0x12 joe.o