From: Mark Wielaard <mark@klomp.org>
To: Ulf Hermann <ulf.hermann@theqtcompany.com>
Cc: elfutils-devel@sourceware.org, Ulf Hermann <ulf.hermann@qt.io>
Subject: Re: [PATCH v2] Make sure packed structs follow the gcc memory layout
Date: Wed, 20 Sep 2017 22:01:00 -0000 [thread overview]
Message-ID: <1505944901.16945.57.camel@klomp.org> (raw)
In-Reply-To: <603c23c4-05f2-4cc9-8081-1065774486c6@email.android.com>
Hi,
Looks like you sent this as HTML-only email, which are rejected by the
mailinglist.
On Mon, 2017-08-21 at 12:57 +0200, Ulf Hermann wrote:
> > 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?
>
> We should generally not rely on the layout of non-packed structs. The
> compiler can insert padding in various places. I didn't find any
> places where we do, though.
I don't think the compiler can do that without breaking ABI. I believe
we are very careful about the in-memory/on-disk struct layout matching.
I am online now and found the documentation:
https://gcc.gnu.org/onlinedocs/gcc/x86-Type-Attributes.html
https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html#index-mms-bitfields
> If packed is used on a structure, or if bit-fields are used, it may
> be that the Microsoft ABI lays out the structure differently than the
> way GCC normally does. Particularly when moving packed data between
> functions compiled with GCC and the native Microsoft compiler (either
> via function call or as data in a file), it may be necessary to
> access either format.
>
> This option is enabled by default for Microsoft Windows targets.
OK, so it is x86-only and it only affects packed structs or if the
struct contains bitfields. Otherwise the layout should be the same.
So I do think your patch is correct. I don't think we ever use structs
that contain bit-fields to map from disk to memory.
Applied to master now.
Thanks,
Mark
next parent reply other threads:[~2017-09-20 22:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <603c23c4-05f2-4cc9-8081-1065774486c6@email.android.com>
2017-09-20 22:01 ` Mark Wielaard [this message]
2017-08-18 12:05 Ulf Hermann
2017-08-19 8:11 ` Mark Wielaard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1505944901.16945.57.camel@klomp.org \
--to=mark@klomp.org \
--cc=elfutils-devel@sourceware.org \
--cc=ulf.hermann@qt.io \
--cc=ulf.hermann@theqtcompany.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).