This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: Problem with structure alignment on MPC


Hi,
 
> just a remark, about my experiences with a H8-cross-gcc: if 
> you declare a 
> public symbol (visible to all other modules), gcc locates 
> this item in a 
> COMMON section (usually .bss, I think). Symbols belonging to 
> one source code file are grouped close to each other, just 
> with the restriction of the CPU's 
> memory access constraint, but: those groups of symbols are 
> page aligned (on 
> H8 0x10).

I can see that when i allocate my structure globaly then it will 2byte
aligned, which is what i want, but it i allocated it locally in the
function then it will be 8byte aligned. This is a bit strange since if i
check where the structures are placed then both the locally and the
global structure are allocated from the .bss section. Regarding the
above mentioned COMMON section, it is placed within the .bss section by
my linker script. However, how is it possible for my two structure to
get different alignment depending on if they are locally allocated or
globally? 

Below is my linker script for the .bss section and i have tried to
change the align(0x8) for the heap to 0x2 instead of 0x8 but i see no
change in the alignment of the structure allocation. I have change all
align(0x8) to (0x2) in the entire file but i see no change.

Furthermore, when i allocate the structure locally then my debugger sais
that the variable is located within the main_stack...which in turn is
located within the .bss. What more can affect the alignment than the
linker script. Why doesnt my changes have any affect?


    .bss   ALIGN (0x10)  :      { __bss_start = ABSOLUTE (.); . = . ;
*(.dynbss*) *(.bss*) *(COMMON) __bss_end = ABSOLUTE (.); } >  ram  
     __heap1   = ALIGN (0x8);
    . = ALIGN(4); _end = .; PROVIDE (end = .); 

> I think, there are 2 solutions, to solve your problem:
> tell gcc '--no-common', so all - even public references - 
> will be located in 
> .bss, as close as possible, or
> declare your test1 'static' (that's cleaner coding, AFAISI)

The option -fno-common doesnt work. No change of alignment. Probably
because the common section is mapped to the .bss section in the linker
script. The static option works fine. However, i dont want to go through
all my code and put my variables globally OR make them static declared,
there must be another option to force the alignment for a section to a
2byte limit...?

Regards, Daniel Lidsten
 

------
Want more information?  See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]