Actions

icon Post
text/html Subscribe
text/html Unsubscribe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

-te500v2 and packed attribute


  • To: power-gnu-discuss@xxxxxxxxxxxxxxxx
  • Subject: -te500v2 and packed attribute
  • From: "S. Couture & K. Musgrove" <muscou@xxxxxxxxxxxx>
  • Date: Tue, 06 May 2008 23:50:48 -0400

This seem to be a bug, the code generated is byte access only.

# cat test.c



# cat test.c
struct a_packed{
   int data;
} __attribute__((packed));
struct a_unpacked{
   int data;
};
void test_packed(int in)
{ struct a_packed * ptr;
   ptr->data = in;
}
void test_unpacked(int in)
{ struct a_unpacked * ptr;
   ptr->data = in;
}


# powerpc-linux-gnu-gcc -O2  -te500v2 test.c -c -o test
# powerpc-linux-gnu-objdump -d test

test:     file format elf32-powerpc

Disassembly of section .text:

00000000 <test_packed>:
  0:    54 69 86 3e     rlwinm  r9,r3,16,24,31
  4:    54 60 46 3e     rlwinm  r0,r3,8,24,31
  8:    54 6b c6 3e     rlwinm  r11,r3,24,24,31
  c:    98 69 00 03     stb     r3,3(r9)
 10:    98 09 00 00     stb     r0,0(r9)
 14:    99 29 00 01     stb     r9,1(r9)
 18:    99 69 00 02     stb     r11,2(r9)
 1c:    4e 80 00 20     blr

00000020 <test_unpacked>:
 20:    90 69 00 00     stw     r3,0(r9)
 24:    4e 80 00 20     blr

# powerpc-linux-gnu-gcc -O2  test.c -c -o test
# powerpc-linux-gnu-objdump -d test

test:     file format elf32-powerpc

Disassembly of section .text:

00000000 <test_packed>:
  0:    90 69 00 00     stw     r3,0(r9)
  4:    4e 80 00 20     blr

00000008 <test_unpacked>:
  8:    90 69 00 00     stw     r3,0(r9)
  c:    4e 80 00 20     blr

I had to align the structure to make it work :

struct a_packed{
   int data;
} __attribute__((packed,aligned(4)));


I would consider this a bug. Is there a better way to fix this then us having to go trough all the packed structure definitions in our code?

Thanks/