aboutsummaryrefslogtreecommitdiffstats
path: root/symbol.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2004-11-03 11:15:31 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-07 21:03:56 -0700
commit7b2c0dd684380c32339d6f9b27b9009f40cfcc94 (patch)
tree0456ee0c9ec40b8a2f6d1f665f2d770db1ed05de /symbol.c
parentd2a83ca97c6f0432e196466633257b08a36bae17 (diff)
downloadsparse-7b2c0dd684380c32339d6f9b27b9009f40cfcc94.tar.gz
Fix up structure bitfield placement.
The change in bitfield symbol bit_size means that structure placement needs to get the size of the base type by walking it explicitly.
Diffstat (limited to 'symbol.c')
-rw-r--r--symbol.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/symbol.c b/symbol.c
index d6ec4a35..19afda0b 100644
--- a/symbol.c
+++ b/symbol.c
@@ -85,6 +85,15 @@ static void lay_out_union(struct symbol *sym, struct struct_union_info *info)
sym->offset = 0;
}
+static int bitfield_base_size(struct symbol *sym)
+{
+ if (sym->type == SYM_NODE)
+ sym = sym->ctype.base_type;
+ if (sym->type == SYM_BITFIELD)
+ sym = sym->ctype.base_type;
+ return sym->bit_size;
+}
+
/*
* Structures are a bit more interesting to lay out
*/
@@ -120,7 +129,7 @@ static void lay_out_struct(struct symbol *sym, struct struct_union_info *info)
*/
if (is_bitfield_type (sym)) {
unsigned long bit_offset = bit_size & align_bit_mask;
- int room = base_size - bit_offset;
+ int room = bitfield_base_size(sym) - bit_offset;
// Zero-width fields just fill up the unit.
int width = sym->fieldwidth ? sym->fieldwidth : (bit_offset ? room : 0);