This is the mail archive of the
ecos-discuss@sources.redhat.com
mailing list for the eCos project.
Gcc 3.0.3, mips64, structure sizes
- From: Chris Morrow <cmorrow at YottaYotta dot com>
- To: ecos-discuss at sources dot redhat dot com
- Date: Fri, 08 Feb 2002 10:40:47 -0700
- Subject: [ECOS] Gcc 3.0.3, mips64, structure sizes
- Organization: YottaYotta Inc.
Gcc 3.0.3 (configured as mips64-unknown-elf) has changed some
behavour with how the size of C++ classes are padded.
In particular in the following code, the size of Cyg_ThreadTimer
is 8 bytes smaller than the corresponding C structure.
typedef unsigned long long cyg_tick_count;
typedef int cyg_bool;
struct cyg_alarm {
void *next;
void *counter;
void *alarm;
int *data;
cyg_tick_count trigger;
cyg_tick_count interval;
cyg_bool enabled;
};
struct cyg_threadtimer {
struct cyg_alarm alarm;
void *thread;
};
class Cyg_Alarm {
public:
void *next;
void *counter;
void *alarm;
int *data;
cyg_tick_count trigger;
cyg_tick_count interval;
cyg_bool enabled;
};
class Cyg_ThreadTimer : public Cyg_Alarm {
public:
void *thread;
};
int
_start(int argc, char *argv[])
{
cyg_threadtimer *ctt = (cyg_threadtimer *)0;
Cyg_ThreadTimer *CTT = (Cyg_ThreadTimer *)0;
ctt->alarm.next = (void *)1;
ctt->alarm.counter = (void *)2;
ctt->alarm.alarm = (void *)3;
ctt->alarm.data = (int *)4;
ctt->alarm.trigger = 5;
ctt->alarm.interval = 6;
ctt->alarm.enabled = 7;
ctt->thread = (void *)8;
CTT->next = (void *)1;
CTT->counter = (void *)2;
CTT->alarm = (void *)3;
CTT->data = (int *)4;
CTT->trigger = 5;
CTT->interval = 6;
CTT->enabled = 7;
CTT->thread = (void *)8;
}
It would appear, based on the following assembly listing that
the compiler is ignoring normal C structure aligment rules
when dealing with inherited classes. Not, a bug really, but
this has interesting consequences for eCos.
.stabn 68,0,38,$LM1
.stabs "t.cxx",132,0,0,$Ltext0
.ent _Z6_startiPPc
_Z6_startiPPc:
.frame $fp,416,$31 # vars= 408, regs= 1/0, args= 0, extra= 0
.mask 0x40000000,-8
.fmask 0x00000000,0
subu $sp,$sp,416
$LCFI0:
sd $fp,408($sp)
$LCFI1:
move $fp,$sp
$LCFI2:
sw $4,420($fp)
sw $5,428($fp)
$LBB2:
$LM2:
.stabn 68,0,39,$LM2
sw $0,0($fp)
$LM3:
.stabn 68,0,40,$LM3
sw $0,4($fp)
$LM4:
.stabn 68,0,44,$LM4
li $3,1 # 0x1
lw $2,0($fp)
sw $3,0($2)
$LM5:
.stabn 68,0,45,$LM5
li $3,2 # 0x2
lw $2,0($fp)
sw $3,4($2)
$LM6:
.stabn 68,0,46,$LM6
li $3,3 # 0x3
lw $2,0($fp)
sw $3,8($2)
$LM7:
.stabn 68,0,47,$LM7
li $3,4 # 0x4
lw $2,0($fp)
sw $3,12($2)
$LM8:
.stabn 68,0,48,$LM8
dli $3,0x5 # 5
lw $2,0($fp)
sd $3,16($2)
$LM9:
.stabn 68,0,49,$LM9
dli $3,0x6 # 6
lw $2,0($fp)
sd $3,24($2)
$LM10:
.stabn 68,0,50,$LM10
li $3,7 # 0x7
lw $2,0($fp)
sw $3,32($2)
$LM11:
.stabn 68,0,51,$LM11
li $3,8 # 0x8
lw $2,0($fp)
sw $3,40($2)
$LM12:
.stabn 68,0,53,$LM12
li $3,1 # 0x1
lw $2,4($fp)
sw $3,0($2)
$LM13:
.stabn 68,0,54,$LM13
li $3,2 # 0x2
lw $2,4($fp)
sw $3,4($2)
$LM14:
.stabn 68,0,55,$LM14
li $3,3 # 0x3
lw $2,4($fp)
sw $3,8($2)
$LM15:
.stabn 68,0,56,$LM15
li $3,4 # 0x4
lw $2,4($fp)
sw $3,12($2)
$LM16:
.stabn 68,0,57,$LM16
dli $3,0x5 # 5
lw $2,4($fp)
sd $3,16($2)
$LM17:
.stabn 68,0,58,$LM17
dli $3,0x6 # 6
lw $2,4($fp)
sd $3,24($2)
$LM18:
.stabn 68,0,59,$LM18
li $3,7 # 0x7
lw $2,4($fp)
sw $3,32($2)
$LM19:
.stabn 68,0,60,$LM19
li $3,8 # 0x8
lw $2,4($fp)
sw $3,36($2) [ this is at offset 40 in old compiler ].
Have people tried gcc 3.0.3 with a mips32 configured compiler?
--
Chris Morrow YottaYotta Inc. email: cmorrow@yottayotta.com
phone: (780) 989 6814 web: http: //www.yottayotta.com