reorganize: Adjust padding after moving from the tail
When we move fields from the tail to eliminate holes look if the struct still correctly fits into a multiple of cu->addr_size. Unless the struct is explicitely marked __attribute__((packed)) (and we can't know that for sure) we have to add padding in that case. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
d46525e7ce
commit
44085cc239
|
@ -771,6 +771,7 @@ void class__reorganize(struct class *self, const struct cu *cu,
|
|||
const int verbose, FILE *fp)
|
||||
{
|
||||
struct class_member *member, *brother, *last_member;
|
||||
size_t modulo;
|
||||
|
||||
class__fixup_member_types(self, cu, verbose, fp);
|
||||
|
||||
|
@ -788,6 +789,13 @@ restart:
|
|||
if (last_member == NULL)
|
||||
return;
|
||||
|
||||
modulo = (last_member->byte_offset +
|
||||
last_member->byte_size) % cu->addr_size;
|
||||
if (modulo != 0) {
|
||||
self->padding = cu->addr_size - modulo;
|
||||
self->type.size += self->padding;
|
||||
}
|
||||
|
||||
type__for_each_data_member(&self->type, member) {
|
||||
/* See if we have a hole after this member */
|
||||
if (member->hole != 0) {
|
||||
|
|
Loading…
Reference in New Issue