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