diff --git a/dwarves.h b/dwarves.h index 254cfe4..d00e89e 100644 --- a/dwarves.h +++ b/dwarves.h @@ -69,6 +69,7 @@ struct conf_fprintf { uint8_t rel_offset:1; uint8_t emit_stats:1; uint8_t suppress_comments:1; + uint8_t suppress_aligned_attribute:1; uint8_t suppress_offset_comment:1; uint8_t show_decl_info:1; uint8_t show_only_data_members:1; diff --git a/dwarves_fprintf.c b/dwarves_fprintf.c index 346aa42..62826bc 100644 --- a/dwarves_fprintf.c +++ b/dwarves_fprintf.c @@ -774,7 +774,7 @@ static size_t class_member__fprintf(struct class_member *member, bool union_memb printed += fprintf(fp, ":%u", member->bitfield_size); } - if (member->alignment != 0) + if (!sconf.suppress_aligned_attribute && member->alignment != 0) printed += fprintf(fp, " __attribute__((__aligned__(%u))", member->alignment); fputc(';', fp); diff --git a/man-pages/pahole.1 b/man-pages/pahole.1 index b05041d..94cffdf 100644 --- a/man-pages/pahole.1 +++ b/man-pages/pahole.1 @@ -167,9 +167,14 @@ Show CUs where CLASS_NAME (-C) is defined. .TP .B \-\-flat_arrays Flatten arrays, so that array[10][2] becomes array[20]. -Useful when generating from both CTF and DWARF encodings +Useful when generating from both CTF/BTF and DWARF encodings for the same binary for testing purposes. +.TP +.B \-\-suppress_aligned_attribute +Suppress forced alignment markers, so that one can compare BTF or +CTF output, that don't have that info, to output from DWARF >= 5. + .TP .B \-\-fixup_silly_bitfields Converts silly bitfields such as "int foo:32" to plain "int foo". diff --git a/pahole.c b/pahole.c index 74ea39e..c0204b1 100644 --- a/pahole.c +++ b/pahole.c @@ -749,6 +749,7 @@ ARGP_PROGRAM_VERSION_HOOK_DEF = dwarves_print_version; #define ARGP_first_obj_only 303 #define ARGP_classes_as_structs 304 #define ARGP_hex_fmt 305 +#define ARGP_suppress_aligned_attribute 306 static const struct argp_option pahole__options[] = { { @@ -946,6 +947,11 @@ static const struct argp_option pahole__options[] = { .key = ARGP_flat_arrays, .doc = "Flat arrays", }, + { + .name = "suppress_aligned_attribute", + .key = ARGP_suppress_aligned_attribute, + .doc = "Suppress __attribute__((aligned(N))", + }, { .name = "show_private_classes", .key = ARGP_show_private_classes, @@ -1046,6 +1052,8 @@ static error_t pahole__options_parser(int key, char *arg, break; case 'Z': ctf_encode = 1; break; case ARGP_flat_arrays: conf.flat_arrays = 1; break; + case ARGP_suppress_aligned_attribute: + conf.suppress_aligned_attribute = 1; break; case ARGP_show_private_classes: show_private_classes = true; conf.show_only_data_members = 1; break;