1// REQUIRES: x86
2// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
3// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/vs-diagnostics-duplicate2.s -o %t2.o
4// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/vs-diagnostics-duplicate3.s -o %t3.o
5// RUN: not ld.lld --vs-diagnostics %t1.o %t2.o %t3.o -o /dev/null 2>&1 | FileCheck %s
6
7// Case 1. Both symbols have full source location.
8// CHECK:      duplicate.s(15): error: duplicate symbol: bar
9// CHECK-NEXT: >>> defined at duplicate.s:15
10// CHECK-NEXT: >>>{{.*}}1.o:(.text+0x{{.+}})
11// CHECK:      duplicate2.s(20): error: duplicate symbol: bar
12// CHECK-NEXT: >>> defined at duplicate2.s:20
13// CHECK-NEXT: >>>{{.*}}2.o:(.text+0x{{.+}})
14
15// Case 2. The source locations are unknown for both symbols.
16// CHECK:      {{.*}}ld.lld{{.*}}: error: duplicate symbol: foo
17// CHECK-NEXT: >>> defined at {{.*}}1.o:(.text+0x{{.+}})
18// CHECK-NEXT: >>> defined at {{.*}}2.o:(.text+0x{{.+}})
19
20// Case 3. For the second definition of `baz` we know only the source file found in a STT_FILE symbol.
21// CHECK:      duplicate.s(30): error: duplicate symbol: baz
22// CHECK-NEXT: >>> defined at duplicate.s:30
23// CHECK-NEXT: >>> {{.*}}1.o:(.text+0x{{.+}})
24// CHECK-NEXT: >>> defined at duplicate3.s
25// CHECK-NEXT: >>>            {{.*}}3.o:(.text+0x{{.+}})
26
27// Check that we prefer using the full path of a source file.
28// CHECK:      /tmp{{/|\\}}duplicate.s(33): error: duplicate symbol: qux
29// CHECK-NEXT: >>> defined at duplicate.s:33 (/tmp{{/|\\}}duplicate.s:33)
30// CHECK-NEXT: >>> {{.*}}1.o:(.text+0x{{.+}})
31// CHECK-NEXT: >>> defined at duplicate3.s
32// CHECK-NEXT: >>>            {{.*}}3.o:(.text+0x{{.+}})
33
34.global _start, foo, bar, baz, qux
35.text
36_start:
37  nop
38
39foo:
40  nop
41
42.file 1 "duplicate.s"
43.loc 1 15
44
45bar:
46  nop
47
48.loc 1 30
49baz:
50  nop
51
52.file 2 "/tmp" "duplicate.s"
53.loc 2 33
54qux:
55  nop
56
57.section .debug_abbrev,"",@progbits
58  .byte  1                      # Abbreviation Code
59  .byte 17                      # DW_TAG_compile_unit
60  .byte  0                      # DW_CHILDREN_no
61  .byte 16                      # DW_AT_stmt_list
62  .byte 23                      # DW_FORM_sec_offset
63  .byte  0                      # EOM(1)
64  .byte  0                      # EOM(2)
65  .byte  0                      # EOM(3)
66
67.section .debug_info,"",@progbits
68  .long .Lend0 - .Lbegin0       # Length of Unit
69.Lbegin0:
70  .short 4                      # DWARF version number
71  .long  .debug_abbrev          # Offset Into Abbrev. Section
72  .byte  8                      # Address Size (in bytes)
73  .byte  1                      # Abbrev [1] 0xb:0x1f DW_TAG_compile_unit
74  .long  .debug_line            # DW_AT_stmt_list
75.Lend0:
76  .section .debug_line,"",@progbits
77