aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Raillard <douglas.raillard@arm.com>2021-10-18 14:16:20 +0100
committerArnaldo Carvalho de Melo <acme@redhat.com>2021-10-26 11:29:55 -0300
commite975d0fba833d02d363369460b04945c6a8dcb9c (patch)
treeb124fcee7ae82abdc005cca7b774b576d4ba4d07
parent5282feee6d4d3a88da64f91de282c89b9e4f9673 (diff)
downloaddwarves-e975d0fba833d02d363369460b04945c6a8dcb9c.tar.gz
btf_loader: Refactor class__fixup_btf_bitfields
Refactor class__fixup_btf_bitfields to remove a "continue" statement, to prepare the ground for alignment fixup that is relevant for some types matching: type->tag != DW_TAG_base_type && type->tag != DW_TAG_enumeration_type Committer testing: btfdiff passes for a x86_64 kernel built with gcc and for a clang thin-LTO vmlinux build. Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Douglas Raillard <douglas.raillard@arm.com> Cc: dwarves@vger.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r--btf_loader.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/btf_loader.c b/btf_loader.c
index 3e5a945..9c2daee 100644
--- a/btf_loader.c
+++ b/btf_loader.c
@@ -486,28 +486,27 @@ static int class__fixup_btf_bitfields(struct tag *tag, struct cu *cu)
pos->byte_size = tag__size(type, cu);
pos->bit_size = pos->byte_size * 8;
- /* bitfield fixup is needed for enums and base types only */
- if (type->tag != DW_TAG_base_type && type->tag != DW_TAG_enumeration_type)
- continue;
-
/* if BTF data is incorrect and has size == 0, skip field,
* instead of crashing */
if (pos->byte_size == 0) {
continue;
}
- if (pos->bitfield_size) {
- /* bitfields seem to be always aligned, no matter the packing */
- pos->byte_offset = pos->bit_offset / pos->bit_size * pos->bit_size / 8;
- pos->bitfield_offset = pos->bit_offset - pos->byte_offset * 8;
- /* re-adjust bitfield offset if it is negative */
- if (pos->bitfield_offset < 0) {
- pos->bitfield_offset += pos->bit_size;
- pos->byte_offset -= pos->byte_size;
- pos->bit_offset = pos->byte_offset * 8 + pos->bitfield_offset;
+ /* bitfield fixup is needed for enums and base types only */
+ if (type->tag == DW_TAG_base_type || type->tag == DW_TAG_enumeration_type) {
+ if (pos->bitfield_size) {
+ /* bitfields seem to be always aligned, no matter the packing */
+ pos->byte_offset = pos->bit_offset / pos->bit_size * pos->bit_size / 8;
+ pos->bitfield_offset = pos->bit_offset - pos->byte_offset * 8;
+ /* re-adjust bitfield offset if it is negative */
+ if (pos->bitfield_offset < 0) {
+ pos->bitfield_offset += pos->bit_size;
+ pos->byte_offset -= pos->byte_size;
+ pos->bit_offset = pos->byte_offset * 8 + pos->bitfield_offset;
+ }
+ } else {
+ pos->byte_offset = pos->bit_offset / 8;
}
- } else {
- pos->byte_offset = pos->bit_offset / 8;
}
}