This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
packed, initialized structures
- To: gcc-bugs at gcc dot gnu dot org
- Subject: packed, initialized structures
- From: "Colin Burgess" <cburgess at qnx dot com>
- Date: Mon, 12 Nov 2001 14:50:24 -0500 (est)
The following code...
struct _leds {
char * ledName;
unsigned char nStdLed;
} __attribute__((packed));
static struct _leds aLeds[] =
{
{"Scroll_Lock", 1},
{"Num_Lock", 2},
{"Caps_Lock", 3}
};
produces an array of structures, each one 5 bytes in size.
However, the initialized data is not packed
.file 1 "bug.c"
gcc2_compiled.:
__gnu_compiled_c:
.data
.align 2
aLeds:
.word $LC0
.byte 1
.word $LC1
.byte 2
.word $LC2
.byte 3
.rdata
.align 2
$LC2:
.ascii "Caps_Lock\000"
.align 2
$LC1:
.ascii "Num_Lock\000"
.align 2
$LC0:
.ascii "Scroll_Lock\000"
.size aLeds,15
bug.o: file format elf32-littlemips
Disassembly of section .data:
00000000 <aLeds>:
0: 00000018 mult $zero,$zero
4: 00000001 0x1
8: 0000000c syscall
c: 00000002 srl $zero,$zero,0x0
10: 00000000 nop
14: 00000003 sra $zero,$zero,0x0
...
The problem seems to be in assemble_variable, where
the alignment of the data is figured, since it doesn't
take maximum_field_alignment into account.
--
cburgess@qnx.com