[PATCH] D94670: [DebugInfo][NFC] add a new DIE type to represent label + offset

ChenZheng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 15 03:57:55 PST 2021


shchenz added a comment.

In D94670#2500531 <https://reviews.llvm.org/D94670#2500531>, @echristo wrote:

> Can you provide a little more detail on the motivation here? Thanks!
>
> -eric

Hi Eric, thanks very much for looking into this.

Background of this patch:
1: we are going to support dwarf for XCOFF(running on AIX).
2: On AIX, the assembler does not need the assembly file contains the dwarf sections length info in the dwarf section header(if the dwarf section has header.) Instead, the assembler will insert the calculated length into dwarf sections header of the final object according to DWARF type. Namely AIX assembler will insert 4 bytes in each section header for DWARF32 and 12 bytes for DWARF64.

For now, in compiler, dwarf section refers to other section by emit other section label in the required place. For example, in .debug_info section, it needs a relocation to indicate where the .debug_line section is. So normally the output assembly file is like:

          .section        .debug_info
  .Ldebug_info:
          .long   (length of .debug_info) # Length of Unit
          .short version_number
          .....
          .long   .Ldebug_line             # DW_AT_stmt_list  #      refer to .debug_line table
  
          .section        .debug_line
  .Ldebug_line:
          .long  (length of .debug_line)
          .short version_number

For now, the reference to .debug_line always has no offset, because on all current supported arch, .debug_line contains the length info.

But for XCOFF, as assembler does not need the length and it will insert the length info at the start of .debug_line, so the reference to `.debug_line` is not accurate in the final object if we still use ` .Ldebug_line`. We need to consider the assembler insertion bytes when we add the reference in compiler. The final assembly on XCOFF is like, taking DWARF32 as example:

         .section        .debug_info
  .Ldebug_info:
          ###### .long   (length of .debug_info) # Length of Unit, this is not required any more
          .short version_number
          .....
          .long   .Ldebug_line-4            # DW_AT_stmt_list  ### refer to .debug_line table, but we need to refer to the previous 4 bytes as assembler will insert 4 bytes for the length field at the front of .debug_line.
  
          .section        .debug_line
  .Ldebug_line:
          ######.long  (length of .debug_line)      #this is not required any more
          .short version_number

So here we need the DIE type label + offset and the offset is negative. We will use the new type in `DwarfCompileUnit::initStmtList()` where we generate attribute `DW_AT_stmt_list` for the root DIE.

Hope I have made myself clear. Thanks again for your review.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94670/new/

https://reviews.llvm.org/D94670



More information about the llvm-commits mailing list