Alignment of LinuxBIOS table structures

Stefan Reinauer stepan at openbios.org
Fri Nov 26 04:55:00 CET 2004


Hi,

I got an interesting report today from a customer having problems 
with building LinuxBIOS and the payload with different compilers

The problem is that different compilers handle structure alignment
differently, ie 2.95.x and 3.x have fundamental differences here:

Adding __attribute__ ((packed)) to the structures helps:

struct lb_memory_range {
	uint64_t start;
	uint64_t size;
	uint32_t type;
#define LB_MEM_RAM       1	/* Memory anyone can use */
#define LB_MEM_RESERVED  2	/* Don't use this memory region */
#define LB_MEM_TABLE     16	/* Ram configuration tables are kept in */
	
} __attribute__ ((packed)); 

struct lb_memory {
	uint32_t tag;
	uint32_t size;
	struct lb_memory_range map[0];
} __attribute__ ((packed));

Since this is a table that is passed in memory, we do want it to be
exactly as it is defined, with no extra padding of any kind to make it
reliable information. So I consider adding __attribute__ ((packed))
a good solution for the problem.

If I get no good reasons against adding this, I will check it in later

Stefan




More information about the coreboot mailing list