Re: [PATCH pahole 1/4] dwarves: revert semantics of member bit/byte hole

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Wed, 2019-04-03 at 10:19 -0300, Arnaldo Carvalho de Melo wrote:
> Most are false positives, as DWARF (let alone BTF) has explicit ways
> to tell that these are all __attribute__((aligned(something)) and
> pahole still don't infer those by realizing that its not a natural
> alignment, a heuristic that would catch most of these bigger holes,
> such as:

DWARF does have DW_AT_alignment and GCC8 does output it.

   DW_AT_alignment Non-default alignment of type, subprogram or
   variable

   2.24 Alignment

   A debugging information entry may have a DW_AT_alignment attribute
   whose value of class constant is a positive, non-zero, integer
   describing the alignment of the entity.

   For example, an alignment attribute whose value is 8 indicates that
   the entity to which it applies occurs at an address that is a
   multiple of eight (not a multiple of 2^8 or 256).

$ cat align.c 
struct tt {
  char *ptr;
  int __attribute__((__aligned__(64))) i;
  int n;
} t;

$ gcc -g -c align.c
$ eu-readelf --debug-dump=info align.o

DWARF section [ 4] '.debug_info' at offset 0x40:
 [Offset]
 Compilation unit at offset 0:
 Version: 4, Abbreviation section offset: 0, Address size: 8, Offset
size: 4
 [     b]  compile_unit         abbrev: 1
           producer             (strp) "GNU C17 8.2.1 20180905 (Red Hat
8.2.1-3) -mtune=generic -march=x86-64 -g"
           language             (data1) C99 (12)
           name                 (strp) "align.c"
           comp_dir             (strp) "/tmp"
           stmt_list            (sec_offset) 0
 [    1d]    structure_type       abbrev: 2
             name                 (string) "tt"
             byte_size            (data1) 128
             alignment            (data1) 64
             decl_file            (data1) align.c (1)
             decl_line            (data1) 1
             decl_column          (data1) 8
             sibling              (ref4) [    4f]
 [    2a]      member               abbrev: 3
               name                 (string) "ptr"
               decl_file            (data1) align.c (1)
               decl_line            (data1) 2
               decl_column          (data1) 9
               type                 (ref4) [    4f]
               data_member_location (data1) 0
 [    37]      member               abbrev: 4
               name                 (string) "i"
               decl_file            (data1) align.c (1)
               decl_line            (data1) 3
               decl_column          (data1) 40
               type                 (ref4) [    5c]
HERE =>        alignment            (data1) 64
               data_member_location (data1) 40
 [    43]      member               abbrev: 3
               name                 (string) "n"
               decl_file            (data1) align.c (1)
               decl_line            (data1) 4
               decl_column          (data1) 7
               type                 (ref4) [    5c]
               data_member_location (data1) 44
 [    4f]    pointer_type         abbrev: 5
             byte_size            (data1) 8
             type                 (ref4) [    55]
 [    55]    base_type            abbrev: 6
             byte_size            (data1) 1
             encoding             (data1) signed_char (6)
             name                 (strp) "char"
 [    5c]    base_type            abbrev: 7
             byte_size            (data1) 4
             encoding             (data1) signed (5)
             name                 (string) "int"
 [    63]    variable             abbrev: 8
             name                 (string) "t"
             decl_file            (data1) align.c (1)
             decl_line            (data1) 5
             decl_column          (data1) 3
             type                 (ref4) [    1d]
             external             (flag_present) yes
             location             (exprloc) 
              [ 0] addr .bss+0



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux