Joel Jones | a5752e1 | 2018-06-06 13:56:51 +0000 | [diff] [blame] | 1 | // REQUIRES: x86 |
George Rimar | 82f0c42 | 2017-11-01 07:42:38 +0000 | [diff] [blame] | 2 | # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o |
| 3 | # RUN: llvm-dwarfdump %t.o | FileCheck -check-prefix=INPUT %s |
| 4 | # RUN: not ld.lld %t.o %t.o -o %t 2>&1 | FileCheck %s |
| 5 | |
| 6 | # INPUT: .debug_info contents: |
| 7 | # INPUT: DW_TAG_variable |
| 8 | # INPUT-NEXT: DW_AT_name ("foo") |
| 9 | # INPUT-NEXT: DW_AT_decl_file ("1.c") |
| 10 | # INPUT-NEXT: DW_AT_decl_line (1) |
Matt Morehouse | 915b4db | 2018-03-07 19:18:14 +0000 | [diff] [blame] | 11 | # INPUT-NEXT: DW_AT_type (0x00000032 "int") |
George Rimar | 82f0c42 | 2017-11-01 07:42:38 +0000 | [diff] [blame] | 12 | # INPUT-NEXT: DW_AT_external (true) |
| 13 | # INPUT-NEXT: DW_AT_location (DW_OP_addr 0x0) |
| 14 | # INPUT: DW_TAG_variable |
| 15 | # INPUT-NEXT: DW_AT_name ("bar") |
| 16 | # INPUT-NEXT: DW_AT_decl_file ("1.c") |
| 17 | # INPUT-NEXT: DW_AT_decl_line (2) |
Matt Morehouse | 915b4db | 2018-03-07 19:18:14 +0000 | [diff] [blame] | 18 | # INPUT-NEXT: DW_AT_type (0x00000032 "int") |
George Rimar | 82f0c42 | 2017-11-01 07:42:38 +0000 | [diff] [blame] | 19 | # INPUT-NEXT: DW_AT_external (true) |
| 20 | # INPUT-NEXT: DW_AT_location (DW_OP_addr 0x0) |
| 21 | |
| 22 | ## Check we use information from .debug_info in messages. |
| 23 | # CHECK: duplicate symbol: bar |
| 24 | # CHECK-NEXT: >>> defined at 1.c:2 |
| 25 | # CHECK-NEXT: >>> {{.*}}:(bar) |
| 26 | # CHECK-NEXT: >>> defined at 1.c:2 |
| 27 | # CHECK-NEXT: >>> {{.*}}:(.data+0x0) |
| 28 | # CHECK: duplicate symbol: foo |
| 29 | # CHECK-NEXT: >>> defined at 1.c:1 |
| 30 | # CHECK-NEXT: >>> {{.*}}:(foo) |
| 31 | # CHECK-NEXT: >>> defined at 1.c:1 |
| 32 | # CHECK-NEXT: >>> {{.*}}:(.bss+0x0) |
| 33 | |
George Rimar | ddd2424 | 2017-11-04 08:20:30 +0000 | [diff] [blame] | 34 | ## Check that stripping debug sections does not break error reporting. |
| 35 | # RUN: not ld.lld --strip-debug %t.o %t.o -o %t 2>&1 | FileCheck %s |
| 36 | |
George Rimar | 82f0c42 | 2017-11-01 07:42:38 +0000 | [diff] [blame] | 37 | # Used reduced output from following code and gcc 7.1.0 |
| 38 | # to produce this input file: |
| 39 | # Source (1.c): |
| 40 | # int foo = 0; |
| 41 | # int bar = 1; |
George Rimar | aef7413 | 2018-07-04 14:04:59 +0000 | [diff] [blame] | 42 | # static int zed = 3; |
George Rimar | 82f0c42 | 2017-11-01 07:42:38 +0000 | [diff] [blame] | 43 | # Invocation: g++ -g -S 1.c |
| 44 | |
| 45 | .bss |
| 46 | .globl foo |
| 47 | .type foo, @object |
| 48 | .size foo, 4 |
| 49 | foo: |
| 50 | |
| 51 | .data |
| 52 | .globl bar |
| 53 | .type bar, @object |
| 54 | .size bar, 4 |
| 55 | bar: |
George Rimar | aef7413 | 2018-07-04 14:04:59 +0000 | [diff] [blame] | 56 | .byte 0 |
| 57 | |
| 58 | .local zed |
| 59 | zed: |
George Rimar | 82f0c42 | 2017-11-01 07:42:38 +0000 | [diff] [blame] | 60 | |
| 61 | .text |
| 62 | .file 1 "1.c" |
| 63 | |
| 64 | .section .debug_info,"",@progbits |
George Rimar | aef7413 | 2018-07-04 14:04:59 +0000 | [diff] [blame] | 65 | .long 0x5a # Compile Unit: length = 0x0000004b) |
George Rimar | 82f0c42 | 2017-11-01 07:42:38 +0000 | [diff] [blame] | 66 | .value 0x4 # version = 0x0004 |
| 67 | .long 0 # abbr_offset = 0x0 |
| 68 | .byte 0x8 # addr_size = 0x08 |
| 69 | |
| 70 | .uleb128 0x1 # DW_TAG_compile_unit [1] * |
| 71 | .long 0 # DW_AT_producer [DW_FORM_strp] ( .debug_str[0x00000000] = ) |
| 72 | .byte 0x4 # DW_AT_language [DW_FORM_data1] (DW_LANG_C_plus_plus) |
| 73 | .string "1.c" # DW_AT_name [DW_FORM_string] ("1.c") |
| 74 | .long 0 # DW_AT_comp_dir [DW_FORM_strp] ( .debug_str[0x00000000] = ) |
| 75 | .long 0 # DW_AT_stmt_list [DW_FORM_sec_offset] (0x00000000) |
Rui Ueyama | 1ce416c | 2017-12-12 20:00:30 +0000 | [diff] [blame] | 76 | |
George Rimar | 82f0c42 | 2017-11-01 07:42:38 +0000 | [diff] [blame] | 77 | .uleb128 0x2 # DW_TAG_variable [2] |
| 78 | .string "foo" # DW_AT_name [DW_FORM_string] ("foo") |
| 79 | .byte 0x1 # DW_AT_decl_file [DW_FORM_data1] ("1.c") |
| 80 | .byte 0x1 # DW_AT_decl_line [DW_FORM_data1] (1) |
| 81 | .long 0x32 # DW_AT_type [DW_FORM_ref4] (cu + 0x0032 => {0x00000032}) |
| 82 | .uleb128 0x9 # DW_AT_external [DW_FORM_flag_present] (true) |
Rui Ueyama | 1ce416c | 2017-12-12 20:00:30 +0000 | [diff] [blame] | 83 | .byte 0x3 |
George Rimar | 82f0c42 | 2017-11-01 07:42:38 +0000 | [diff] [blame] | 84 | .quad foo # DW_AT_location [DW_FORM_exprloc] (DW_OP_addr 0x0) |
Rui Ueyama | 1ce416c | 2017-12-12 20:00:30 +0000 | [diff] [blame] | 85 | |
George Rimar | 82f0c42 | 2017-11-01 07:42:38 +0000 | [diff] [blame] | 86 | .uleb128 0x3 # DW_TAG_base_type [3] |
| 87 | .byte 0x4 # DW_AT_byte_size [DW_FORM_data1] (0x04) |
| 88 | .byte 0x5 # DW_AT_encoding [DW_FORM_data1] (DW_ATE_signed) |
| 89 | .string "int" # DW_AT_name [DW_FORM_string] ("int") |
Rui Ueyama | 1ce416c | 2017-12-12 20:00:30 +0000 | [diff] [blame] | 90 | |
George Rimar | 82f0c42 | 2017-11-01 07:42:38 +0000 | [diff] [blame] | 91 | .uleb128 0x2 # DW_TAG_variable [2] |
| 92 | .string "bar" # DW_AT_name [DW_FORM_string] ("bar") |
| 93 | .byte 0x1 # DW_AT_decl_file [DW_FORM_data1] ("1.c") |
| 94 | .byte 0x2 # DW_AT_decl_line [DW_FORM_data1] (2) |
| 95 | .long 0x32 # DW_AT_type [DW_FORM_ref4] (cu + 0x0032 => {0x00000032}) |
| 96 | .uleb128 0x9 # DW_AT_external [DW_FORM_flag_present] (true) |
Rui Ueyama | 1ce416c | 2017-12-12 20:00:30 +0000 | [diff] [blame] | 97 | .byte 0x3 |
George Rimar | 82f0c42 | 2017-11-01 07:42:38 +0000 | [diff] [blame] | 98 | .quad bar # DW_AT_location [DW_FORM_exprloc] (DW_OP_addr 0x0) |
George Rimar | aef7413 | 2018-07-04 14:04:59 +0000 | [diff] [blame] | 99 | |
| 100 | .uleb128 0x4 # DW_TAG_variable [2] |
| 101 | .string "zed" # DW_AT_name [DW_FORM_string] ("zed") |
| 102 | .byte 0x1 # DW_AT_decl_file [DW_FORM_data1] ("1.c") |
| 103 | .byte 0x3 # DW_AT_decl_line [DW_FORM_data1] (2) |
| 104 | .long 0x32 # DW_AT_type [DW_FORM_ref4] (cu + 0x0032 => {0x00000032}) |
| 105 | .quad zed # DW_AT_location [DW_FORM_exprloc] (DW_OP_addr 0x0) |
| 106 | |
George Rimar | 82f0c42 | 2017-11-01 07:42:38 +0000 | [diff] [blame] | 107 | .byte 0 # END |
Rui Ueyama | 1ce416c | 2017-12-12 20:00:30 +0000 | [diff] [blame] | 108 | |
George Rimar | 82f0c42 | 2017-11-01 07:42:38 +0000 | [diff] [blame] | 109 | |
| 110 | .section .debug_abbrev,"",@progbits |
| 111 | .uleb128 0x1 # Abbreviation code. |
| 112 | .uleb128 0x11 # DW_TAG_compile_unit |
Rui Ueyama | 1ce416c | 2017-12-12 20:00:30 +0000 | [diff] [blame] | 113 | |
George Rimar | 82f0c42 | 2017-11-01 07:42:38 +0000 | [diff] [blame] | 114 | .byte 0x1 # ID |
| 115 | .uleb128 0x25 # DW_AT_producer, DW_FORM_strp |
| 116 | .uleb128 0xe |
| 117 | .uleb128 0x13 # DW_AT_language, DW_FORM_data1 |
| 118 | .uleb128 0xb |
| 119 | .uleb128 0x3 # DW_AT_name, DW_FORM_string |
| 120 | .uleb128 0x8 |
| 121 | .uleb128 0x1b # DW_AT_comp_dir, DW_FORM_strp |
| 122 | .uleb128 0xe |
| 123 | .uleb128 0x10 # DW_AT_stmt_list, DW_FORM_sec_offset |
| 124 | .uleb128 0x17 |
| 125 | .byte 0 |
| 126 | .byte 0 |
Rui Ueyama | 1ce416c | 2017-12-12 20:00:30 +0000 | [diff] [blame] | 127 | |
George Rimar | 82f0c42 | 2017-11-01 07:42:38 +0000 | [diff] [blame] | 128 | .uleb128 0x2 # ID |
| 129 | .uleb128 0x34 # DW_TAG_variable, DW_CHILDREN_no |
| 130 | .byte 0 |
| 131 | .uleb128 0x3 # DW_AT_name, DW_FORM_string |
| 132 | .uleb128 0x8 |
| 133 | .uleb128 0x3a # DW_AT_decl_file, DW_FORM_data1 |
| 134 | .uleb128 0xb |
| 135 | .uleb128 0x3b # DW_AT_decl_line, DW_FORM_data1 |
| 136 | .uleb128 0xb |
| 137 | .uleb128 0x49 # DW_AT_type, DW_FORM_ref4 |
| 138 | .uleb128 0x13 |
| 139 | .uleb128 0x3f # DW_AT_external, DW_FORM_flag_present |
| 140 | .uleb128 0x19 |
| 141 | .uleb128 0x2 # DW_AT_location, DW_FORM_exprloc |
| 142 | .uleb128 0x18 |
| 143 | .byte 0 |
| 144 | .byte 0 |
Rui Ueyama | 1ce416c | 2017-12-12 20:00:30 +0000 | [diff] [blame] | 145 | |
George Rimar | 82f0c42 | 2017-11-01 07:42:38 +0000 | [diff] [blame] | 146 | .uleb128 0x3 # ID |
| 147 | .uleb128 0x24 # DW_TAG_base_type, DW_CHILDREN_no |
| 148 | .byte 0 |
| 149 | .uleb128 0xb # DW_AT_byte_size, DW_FORM_data1 |
| 150 | .uleb128 0xb |
| 151 | .uleb128 0x3e # DW_AT_encoding, DW_FORM_data1 |
| 152 | .uleb128 0xb |
| 153 | .uleb128 0x3 # DW_AT_name, DW_FORM_string |
| 154 | .uleb128 0x8 |
| 155 | .byte 0 |
| 156 | .byte 0 |
George Rimar | aef7413 | 2018-07-04 14:04:59 +0000 | [diff] [blame] | 157 | |
| 158 | .uleb128 0x4 # ID |
| 159 | .uleb128 0x34 # DW_TAG_variable, DW_CHILDREN_no |
| 160 | .byte 0 |
| 161 | .uleb128 0x3 # DW_AT_name, DW_FORM_string |
| 162 | .uleb128 0x8 |
| 163 | .uleb128 0x3a # DW_AT_decl_file, DW_FORM_data1 |
| 164 | .uleb128 0xb |
| 165 | .uleb128 0x3b # DW_AT_decl_line, DW_FORM_data1 |
| 166 | .uleb128 0xb |
| 167 | .uleb128 0x49 # DW_AT_type, DW_FORM_ref4 |
| 168 | .uleb128 0x13 |
| 169 | .uleb128 0x2 # DW_AT_location, DW_FORM_exprloc |
| 170 | .uleb128 0x18 |
| 171 | .byte 0 |
George Rimar | 82f0c42 | 2017-11-01 07:42:38 +0000 | [diff] [blame] | 172 | .byte 0 |
| 173 | |
George Rimar | aef7413 | 2018-07-04 14:04:59 +0000 | [diff] [blame] | 174 | .byte 0 |