ARM: Packed structure
David Brown
david.brown@hesbynett.no
Wed Mar 2 21:07:34 GMT 2022
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>
More information about the Gcc-help
mailing list