From 78fad32d8341dde5ccfcbb7793316147ebddba85 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Thu, 22 Mar 2018 17:14:41 +0000 Subject: [PATCH] Make the debug info in some tests more realistic. 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 | 21 +++++++++++++++++++++ lld/test/ELF/Inputs/undef-debug.s | 21 +++++++++++++++++++++ lld/test/ELF/compressed-debug-conflict.s | 21 +++++++++++++++++++++ lld/test/ELF/undef-broken-debug.test | 21 +++++++++++++++++++++ 4 files changed, 84 insertions(+) diff --git a/lld/test/ELF/Inputs/conflict-debug.s b/lld/test/ELF/Inputs/conflict-debug.s index 03fb013..c38771e 100644 --- a/lld/test/ELF/Inputs/conflict-debug.s +++ b/lld/test/ELF/Inputs/conflict-debug.s @@ -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 diff --git a/lld/test/ELF/Inputs/undef-debug.s b/lld/test/ELF/Inputs/undef-debug.s index db8aaf1..46c1c92 100644 --- a/lld/test/ELF/Inputs/undef-debug.s +++ b/lld/test/ELF/Inputs/undef-debug.s @@ -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 diff --git a/lld/test/ELF/compressed-debug-conflict.s b/lld/test/ELF/compressed-debug-conflict.s index 12430fa..e3ebc51 100644 --- a/lld/test/ELF/compressed-debug-conflict.s +++ b/lld/test/ELF/compressed-debug-conflict.s @@ -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 diff --git a/lld/test/ELF/undef-broken-debug.test b/lld/test/ELF/undef-broken-debug.test index 1238ebe..4a61bce 100644 --- a/lld/test/ELF/undef-broken-debug.test +++ b/lld/test/ELF/undef-broken-debug.test @@ -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 -- 2.7.4