Subject: Re: gcc4 lossage on mips kernels with semi-packed struct
To: None <tech-toolchain@NetBSD.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: tech-toolchain
Date: 05/15/2006 23:10:09
> 	struct bootpcontext {
[...]
> 		struct in_addr dhcp_serverip; 

> 	struct in_addr {
> 		uint32_t s_addr;
> 	} __attribute__((__packed__));

> [bcopy to such a bootpcontext's dhcp_serverip generates:]

>         lwl     $2,3($4)
>         lwr     $2,0($4)
>         sw      $2,22($17)

> where sw is an aligned store, which promptly panics when it tries to
> store at an unaligned address.

> Is gcc4 doing something wrong here,

Sounds like it to me.  It's obeying the packed attribute in that it's
putting the struct at an unaligned address, but then forgetting about
it when it comes time to generate code.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B