public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* ARM: Packed structure
@ 2022-03-02 16:29 Barbier, Renaud
  2022-03-02 21:07 ` David Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Barbier, Renaud @ 2022-03-02 16:29 UTC (permalink / raw)
  To: gcc-help

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: ARM: Packed structure
  2022-03-02 16:29 ARM: Packed structure Barbier, Renaud
@ 2022-03-02 21:07 ` David Brown
  0 siblings, 0 replies; 2+ messages in thread
From: David Brown @ 2022-03-02 21:07 UTC (permalink / raw)
  To: Barbier, Renaud, gcc-help

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>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-02 21:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-02 16:29 ARM: Packed structure Barbier, Renaud
2022-03-02 21:07 ` David Brown

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).