From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 56003 invoked by alias); 19 Aug 2017 08:11:33 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 55025 invoked by uid 89); 19 Aug 2017 08:11:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.2 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=0.6 required=5.0 tests=BAYES_00,DATE_IN_PAST_06_12,KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 spammy=H*M:stream X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_00,DATE_IN_PAST_06_12,KAM_LAZY_DOMAIN_SECURITY autolearn=no version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: gnu.wildebeest.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (212.238.236.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 19 Aug 2017 08:11:06 +0000 Received: from stream.wildebeest.org (ADijon-357-1-27-209.w109-217.abo.wanadoo.fr [109.217.50.209]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id A421B3027684; Sat, 19 Aug 2017 10:11:03 +0200 (CEST) Received: by stream.wildebeest.org (Postfix, from userid 1000) id 6BF4B101F93; Fri, 18 Aug 2017 22:49:59 +0200 (CEST) Date: Sat, 19 Aug 2017 08:11:00 -0000 From: Mark Wielaard To: Ulf Hermann Cc: elfutils-devel@sourceware.org Subject: Re: [PATCH v2] Make sure packed structs follow the gcc memory layout Message-ID: <20170818204959.GC3169@stream> References: <01f496b4-a384-64a0-4263-7df28098e8fe@qt.io> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <01f496b4-a384-64a0-4263-7df28098e8fe@qt.io> User-Agent: Mutt/1.8.3 (2017-05-23) X-IsSubscribed: yes X-SW-Source: 2017-q3/txt/msg00090.txt.bz2 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