[coreboot] Coreboot bug?

Myles Watson mylesgw at gmail.com
Wed Nov 11 21:49:44 CET 2009


On Wed, Nov 11, 2009 at 12:31 PM, Myles Watson <mylesgw at gmail.com> wrote:
> src/arch/i386/boot/coreboot_table.c: In function 'write_coreboot_table':
> src/arch/i386/boot/coreboot_table.c:492: warning: dereferencing
> pointer 'rec_src' does break strict-aliasing rules
> src/arch/i386/boot/coreboot_table.c:491: note: initialized from here
>
> #if (CONFIG_HAVE_OPTION_TABLE == 1)
>        {
>                struct lb_record *rec_dest, *rec_src;
>                /* Write the option config table... */
>                rec_dest = lb_new_record(head);
>                rec_src = (struct lb_record *)(void *)&option_table;
>                memcpy(rec_dest,  rec_src, rec_src->size);
>                /* Create cmos checksum entry in coreboot table */
>                lb_cmos_checksum(head);
>        }
> #endif
>
> from option_table.c:
> unsigned char option_table[] = {
>        0xc8,0x00,0x00,0x00,0x88,0x04,0x00,0x00,0x0c,0x00,
> ...
>
> from src/include/boot/coreboot_tables.h:
> struct lb_record {
>        uint32_t tag;           /* tag ID */
>        uint32_t size;          /* size of record (in bytes) */
> };
>
> Why are we casting it as a lb_record * then using that size field in the copy?
All right, I see why it works: 0xc8 is the tag and the size is 0x480
in this case.  Is there a better way to do it that avoids the warning
and makes the code easier to understand?

Thanks,
Myles




More information about the coreboot mailing list