Hi,
"Zuxy Meng" <zuxy.meng@gmail.com> ååæææé:a18e06b40806250021q7b9051bfxc55ce93c63563e3c@mail.gmail.com...
Hi Danny,
2008/6/25 Danny Smith <dansmister@gmail.com>:
On Wed, Jun 25, 2008 at 3:33 PM, Zuxy Meng <zuxy.meng@gmail.com> wrote:
Hi,
Under MinGW32 I got the following results:
C:\MSYS\home\jimeng>type x.c
short b __attribute__((aligned(16)));
C:\MSYS\home\jimeng>objdump -h x.o
x.o: file format pe-i386
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000000 2**2
ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000000 2**2
ALLOC, LOAD, DATA
2 .bss 00000000 00000000 00000000 00000000 2**2
ALLOC
Shouldn't .data be aligned to "2**4" or the "Algn" of an object doesn't
mean
too much?
PE-COFF doesn't support aligned common
Does it mean that uninitialized vars in such objects may get
misaligned when linked together? Or the "aligned" attribute takes
effect only with -fno-common under mingw32?
Compile with -fno-common and you should see .bss aligned correctly
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000000 00000000 00000000 00000000 2**2
ALLOC, LOAD, READONLY, CODE
1 .data 00000000 00000000 00000000 00000000 2**2
ALLOC, LOAD, DATA
2 .bss 00000010 00000000 00000000 00000000 2**4
ALLOC
I met another problem. The alignment for static and global vars are
different:
For a global var
C:\MSYS\home\jimeng>type x.c
short b __attribute__((aligned(16)));
void set(short x)
{
b = x;
}
short get()
{
return b;
}
C:\MSYS\home\jimeng>gcc -fno-common -c x.c
C:\MSYS\home\jimeng>objdump -h x.o
x.o: file format pe-i386
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000028 00000000 00000000 0000008c 2**2
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
1 .data 00000000 00000000 00000000 00000000 2**2
ALLOC, LOAD, DATA
2 .bss 00000010 00000000 00000000 00000000 2**4
ALLOC
But for a static var
C:\MSYS\home\jimeng>type x.c
static short b __attribute__((aligned(16)));
void set(short x)
{
b = x;
}
short get()
{
return b;
}
C:\MSYS\home\jimeng>gcc -fno-common -O2 -c x.c
C:\MSYS\home\jimeng>objdump -h x.o
x.o: file format pe-i386
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00000020 00000000 00000000 0000008c 2**4
CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
1 .data 00000000 00000000 00000000 00000000 2**2
ALLOC, LOAD, DATA
2 .bss 00000010 00000000 00000000 00000000 2**3
ALLOC
Is this by design or a bug?
--
Zuxy