This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: .align problem with i[34]86-*-coff
- To: gcc at gcc dot gnu dot org
- Subject: Re: .align problem with i[34]86-*-coff
- From: Rotter Klaus <Klaus dot Rotter at erl9 dot siemens dot de>
- Date: Tue, 12 Oct 1999 15:02:04 +0200
Hello,
first sorry for mixing up my message with Andreas Jaegers one.
> For debugging reasons I have tried to set up a clean enviroment compiling both binutils
> and
> gcc for i386-unkown-aout (2.95.1). Compiling works, but it turned out that the is a bug
> with structures. My RTOS didn't allow padding bytes in structures, so I use the flag
> -fpack-struct. This worked fine with i586-pc-cygwin, but with i386-unkown-aout gcc aligns
> 32-bit ints in structures to a longword boundary (even with -fpack-struct).
I digged a little deeper into this problem. I have two compilers, one configured
with i386-pc-cygwin32 (build on my own) and the other i586-pc-cygwin (the original
cygwin update by Mumit Khan). Then I have compiled the following program:
typedef struct {
char *ptr;
short s1;
char *ptr2;
short s2;
int flags;
} ST;
ST st = { "Hello", 1, "You", 2, 123456 };
(Well, not really a programm, just a structure)
Compiling with "i586-pc-cygwin32-gcc -S -fpack-struct struct.c" (2.95) gives me:
.file "struct.c"
gcc2_compiled.:
___gnu_compiled_c:
.globl _st
.data
_st:
.long LC0
.word 1
.long LC1
.word 2
.long 123456
.text
LC1:
.ascii "You\0"
LC0:
.ascii "Hello\0"
Compiling with "i386-pc-cygwin32-gcc -S -fpack-struct struct.c" (2.95.1) gives me:
.file "struct.c"
gcc2_compiled.:
___gnu_compiled_c:
.globl _st
.data
.align 4
_st:
.long LC0
.word 1
.space 2
.long LC1
.word 2
.space 2
.long 123456
.text
LC1:
.ascii "You\0"
LC0:
.ascii "Hello\0"
So, either there is a new bug introduced between 2.95 and 2.95.1 (I don't believe
that), or alignment inside structures depends on the processor you choose without
regarding a -fpack-struct option. This is bad, I think it is a bug, because the
the longword alignment is _not_ needed on a i386 or i486, it is only faster (on a
i486, I think).
Unfortunatly, I wasn't able to compare two releases (eg. 2.95.1 compiled for
i386-pc-cygwin and i586-pc-cygwin) because my eviroment is so slow. A gcc build
"make LANGUAGES=c" takes about 2h ;-(. I am still waiting to get it ready...
--
Klaus Rotter, Siemens AG, ATD TD 6 EPG, Postfach 3249, 91020 Erlangen
Tel.: +49 9131 18-84637, Fax: +49 9131 18-84648
mailto:Klaus.Rotter@erl9.siemens.de