Structure alignment problem
Rosetti Andrea
andrea.rosetti@icn.siemens.it
Thu Sep 12 02:47:00 GMT 2002
Hi All,
I use cygnus-2.7.2-960126 cross compiler version.
This is the official version provided by WindRiver Tornado distribution.
My problem is to set the max alignment size for the structure members
because I use different compilers for different targets
and I have compatibility problems.
For example:
struct {
int a;
char b;
int c;
} pippo;
void bye ()
{
pippo.a=4;
pippo.b='4';
pippo.c=9;
}
with Microtec MRI for 68xxx:
; Microtec(R) Research Inc. 68K C Compiler 4.2D
; Host Operating System - SUN4 UNIX
; Command Line Options Specified:
; -Ri/tmp/prova.1 -v prova.c
TTL prova.c
; MCC68K 4.2D S4090391 s42206
OPT NOABSPCADD,E,CASE
NAME prova
XCOM _pippo,10
SECTION code,,C
XDEF _bye
_bye:
moveq #4,d0
move.l d0,_pippo
move.b #52,_pippo+4
moveq #9,d0
move.l d0,_pippo+6 <---
rts
; code: 26 bytes stack: 0 bytes
END
------------------------------
with Diab Data (X76=2, X88=2)
.align 2
.globl bye
bye:
stwu r1,-8(r1)
mfspr r0,lr
stw r0,12(r1)
#$$ee
addis r12,r0,pippo@ha
addi r11,r0,4
stw r11,pippo@l(r12)
addis r10,r0,(pippo+4)@ha
addi r9,r0,52
stb r9,(pippo+4)@l(r10)
addis r12,r0,(pippo+6)@ha
addi r11,r0,9
stw r11,(pippo+6)@l(r12) <---
#$$be
lwz r0,12(r1)
mtspr lr,r0
addi r1,r1,8
#$$tl 0x0 0x0
blr
#$$ef
.type bye,@function
.size bye,.-bye
# Allocations for bye
# Allocations for module
--------------------
with gcc (GNU C version cygnus-2.7.2-960126 PowerPC Embedded)
# GNU C cygnus-2.7.2-960126
# -fpeephole -ffunction-cse -fkeep-static-consts -fpcc-struct-return
-fcommon
# -fgnu-linker -mpowerpc -mnew-mnemonics
.file "prova.c"
gcc2_compiled.:
.section ".text"
.align 2
.globl bye
.type bye,@function
bye:
stwu 1,-16(1)
stw 31,12(1)
mr 31,1
addis 9,0,pippo@ha
addi 11,9,pippo@l
li 0,4
stw 0,0(11)
addis 9,0,pippo@ha
addi 11,9,pippo@l
li 0,52
stb 0,4(11)
addis 9,0,pippo@ha
addi 11,9,pippo@l
li 0,9
stw 0,8(11) <--
.L1:
lwz 11,0(1)
lwz 31,-4(11)
mr 1,11
blr
.Lfe1:
.size bye,.Lfe1-bye
.comm pippo,12,4
.ident "GCC: (GNU) cygnus-2.7.2-960126"
Sorry for my poor english.
Thank you.
Ciao
Andrea
------
Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/
Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com
More information about the crossgcc
mailing list