Make the debug info in some tests more realistic.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 22 Mar 2018 17:14:41 +0000 (17:14 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 22 Mar 2018 17:14:41 +0000 (17:14 +0000)
Currently lld just parses the .debug_line section assuming that there
is only one compile unit. That assumption is false (PR36793).

I have a patch that changes lld to iterate over the compile units and
parse the portions of the .debug_line they point to (which fixes
PR36793).

A problem is that we will then need a compiler unit pointing to
.debug_line for lld to see it.

It seems like bfd has the same restriction.

This patch updates existing tests to add a minimal compile unit so
that they still work with PR36793 fixed.

llvm-svn: 328215

lld/test/ELF/Inputs/conflict-debug.s
lld/test/ELF/Inputs/undef-debug.s
lld/test/ELF/compressed-debug-conflict.s
lld/test/ELF/undef-broken-debug.test

index 03fb013..c38771e 100644 (file)
@@ -3,3 +3,24 @@
 .loc 1 4
 zed:
   nop
+
+       .section        .debug_abbrev,"",@progbits
+       .byte   1                       # Abbreviation Code
+       .byte   17                      # DW_TAG_compile_unit
+       .byte   0                       # DW_CHILDREN_no
+       .byte   16                      # DW_AT_stmt_list
+       .byte   23                      # DW_FORM_sec_offset
+       .byte   0                       # EOM(1)
+       .byte   0                       # EOM(2)
+       .byte   0                       # EOM(3)
+
+        .section       .debug_info,"",@progbits
+       .long   .Lend0 - .Lbegin0       # Length of Unit
+.Lbegin0:
+       .short  4                       # DWARF version number
+       .long   .debug_abbrev           # Offset Into Abbrev. Section
+       .byte   8                       # Address Size (in bytes)
+       .byte   1                       # Abbrev [1] 0xb:0x1f DW_TAG_compile_unit
+       .long   .debug_line             # DW_AT_stmt_list
+.Lend0:
+       .section        .debug_line,"",@progbits
index db8aaf1..46c1c92 100644 (file)
@@ -9,3 +9,24 @@
 .section .text.2,"ax"
 .loc 1 11
         .quad zed5
+
+       .section        .debug_abbrev,"",@progbits
+       .byte   1                       # Abbreviation Code
+       .byte   17                      # DW_TAG_compile_unit
+       .byte   0                       # DW_CHILDREN_no
+       .byte   16                      # DW_AT_stmt_list
+       .byte   23                      # DW_FORM_sec_offset
+       .byte   0                       # EOM(1)
+       .byte   0                       # EOM(2)
+       .byte   0                       # EOM(3)
+
+        .section       .debug_info,"",@progbits
+       .long   .Lend0 - .Lbegin0       # Length of Unit
+.Lbegin0:
+       .short  4                       # DWARF version number
+       .long   .debug_abbrev           # Offset Into Abbrev. Section
+       .byte   8                       # Address Size (in bytes)
+       .byte   1                       # Abbrev [1] 0xb:0x1f DW_TAG_compile_unit
+       .long   .debug_line             # DW_AT_stmt_list
+.Lend0:
+       .section        .debug_line,"",@progbits
index 12430fa..e3ebc51 100644 (file)
@@ -27,3 +27,24 @@ main:
        xorl    %eax, %eax
        retl
        .file   2 "/tmp/repeat/repeat/repeat/repeat" "repeat.h"
+
+       .section        .debug_abbrev,"",@progbits
+       .byte   1                       # Abbreviation Code
+       .byte   17                      # DW_TAG_compile_unit
+       .byte   0                       # DW_CHILDREN_no
+       .byte   16                      # DW_AT_stmt_list
+       .byte   23                      # DW_FORM_sec_offset
+       .byte   0                       # EOM(1)
+       .byte   0                       # EOM(2)
+       .byte   0                       # EOM(3)
+
+        .section       .debug_info,"",@progbits
+       .long   .Lend0 - .Lbegin0       # Length of Unit
+.Lbegin0:
+       .short  4                       # DWARF version number
+       .long   .debug_abbrev           # Offset Into Abbrev. Section
+       .byte   8                       # Address Size (in bytes)
+       .byte   1                       # Abbrev [1] 0xb:0x1f DW_TAG_compile_unit
+       .long   .debug_line             # DW_AT_stmt_list
+.Lend0:
+       .section        .debug_line,"",@progbits
index 1238ebe..4a61bce 100644 (file)
@@ -40,6 +40,27 @@ Sections:
       - Offset:          0x0000000000000029
         Symbol:          bar
         Type:            R_X86_64_64
+  - Name:            .debug_info
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x0000000000000001
+    Content:         0C000000040000000000080100000000
+  - Name:            .rela.debug_info
+    Type:            SHT_RELA
+    Link:            .symtab
+    AddressAlign:    0x0000000000000008
+    Info:            .debug_info
+    Relocations:
+      - Offset:          0x0000000000000006
+        Symbol:          .debug_abbrev
+        Type:            R_X86_64_32
+      - Offset:          0x000000000000000C
+        Symbol:          .debug_line
+        Type:            R_X86_64_32
+  - Name:            .debug_abbrev
+    Type:            SHT_PROGBITS
+    AddressAlign:    0x0000000000000001
+    Content:         '0111001017000000'
+
 Symbols:
   Global:
     - Name:            _start