This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH v2] Make sure packed structs follow the gcc memory layout


On Fri, Aug 18, 2017 at 02:05:10PM +0200, Ulf Hermann wrote:
> gcc defaults to using struct layouts that follow the native conventions,
> even if __attribute__((packed)) is given. In order to get the layout we
> expect, we need to tell gcc to always use the gcc struct layout, at
> least for packed structs. To do this, we can use the gcc_struct
> attribute.
> 
> This is important, not only for porting to windows, but also potentially
> for other platforms, as the bugs resulting from struct layout
> differences are rather subtle and hard to find.

I don't have internet access at the moment to lookup the documentation
for gcc_struct. And none of the sources I have locally at the moment
seem to use gcc_struct. So I am not completely clear on why this is
only needed for packed structs. Wouldn't this be a general problem for
any struct that might be layed out differently but that we might map
to some on-disk data structure?

Cheers,

Mark


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]