From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from spam02.hesby.net (spam01.hesby.net [81.29.32.152]) by sourceware.org (Postfix) with ESMTP id 398FE3858C83 for ; Wed, 2 Mar 2022 21:07:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 398FE3858C83 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=hesbynett.no Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=hesbynett.no Received: from [192.168.4.227] (247.92-221-34.customer.lyse.net [92.221.34.247]) by spam02.hesby.net (Halon) with ESMTPSA id c7c27805-9a6c-11ec-920b-506b8dfa0e58; Wed, 02 Mar 2022 22:07:36 +0100 (CET) Subject: Re: ARM: Packed structure To: "Barbier, Renaud" , "gcc-help@gcc.gnu.org" References: From: David Brown Message-ID: <4a56ab7d-0170-0d61-f5b8-cd1d19d1347f@hesbynett.no> Date: Wed, 2 Mar 2022 22:07:34 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-3033.3 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 02 Mar 2022 21:07:41 -0000 On 02/03/2022 17:29, Barbier, Renaud via Gcc-help wrote: > I am building a boot loader (barebox) with gcc 10.2.0 for a NXP LS1021A for which I intend to use SPD. > > The SPD structure for DDR3 (struct ddr3_spd_eeprom )can be found here: https://git.pengutronix.de/cgit/barebox/tree/include/ddr_spd.h > > The problem I have is that the field after the union are not packed: > > .... > } registered; > unsigned char uc[57]; /* 60-116 Module-Specific Section */ ==> uc[56] is at the right place offset 116 > } mod_section; > > /* Unique Module ID: Bytes 117-125 */ > unsigned char mmid_lsb; /* 117 Module MfgID Code LSB - JEP-106 */ ===> mmid_lsb end up at offset 120 instead of offset 117 > > I tried the __packed attribute without effect > > This is the debug output showing the offset from the start of SPD structure: > uc[56]@ = 0x1000e2cc, 116 > mmid_lsb@ = 0x1000e2d0, 120 ==> should be 117. > > Is there a bug in 10.2.0 that I have not found or a parameter I have not used to build the boot loader that could fix this problem. > > Cheers, > R > It seems fine to me when I tried it on godbolt :