public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Brown <david.brown@hesbynett.no>
To: "Barbier, Renaud" <Renaud.Barbier@ametek.com>,
	"gcc-help@gcc.gnu.org" <gcc-help@gcc.gnu.org>
Subject: Re: ARM: Packed structure
Date: Wed, 2 Mar 2022 22:07:34 +0100	[thread overview]
Message-ID: <4a56ab7d-0170-0d61-f5b8-cd1d19d1347f@hesbynett.no> (raw)
In-Reply-To: <MN2PR16MB31350C9F693E21BF29D24D1791039@MN2PR16MB3135.namprd16.prod.outlook.com>

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 :

<https://godbolt.org/z/r1joYd135>

      reply	other threads:[~2022-03-02 21:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-02 16:29 Barbier, Renaud
2022-03-02 21:07 ` David Brown [this message]

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=4a56ab7d-0170-0d61-f5b8-cd1d19d1347f@hesbynett.no \
    --to=david.brown@hesbynett.no \
    --cc=Renaud.Barbier@ametek.com \
    --cc=gcc-help@gcc.gnu.org \
    /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).