Target support for packed/aligned (1) structs
Tue Apr 4 12:56:00 GMT 2017
For the usual GNU/Linux targets, does GCC support unaligned loads
through pointers to packed structs? That is, something like that:
struct __attribute__ ((may_alias, packed, aligned (1))) header
get_question_count (const void *buf)
const struct header *header = buf;
return ntohs (header->qdcount);
And this should work even if buf is not properly aligned.
I know there are problems if I take the address of a member in struct
header and use that pointer, but I hope that direct use of the member is
This would allow us to simplify some code in glibc and avoid defensive
copies to a properly aligned struct.
More information about the Gcc-help