1# REQUIRES: x86
2
3# RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t.obj
4# RUN: llvm-readobj --symbols %t.obj | FileCheck %s --check-prefix=SYMBOL
5
6# RUN: lld-link -lldmingw -entry:main %t.obj -out:%t.exe -lldmap:%t.map -verbose
7# RUN: llvm-readobj --sections %t.exe | FileCheck %s
8
9# CHECK: Sections [
10# CHECK:   Section {
11# CHECK:     Number: 2
12# CHECK-LABEL:     Name: .rdata (2E 72 64 61 74 61 00 00)
13#             This is the critical check to show that .xdata$foo was
14#             retained, while .xdata$bar wasn't. This *must* be 0x24
15#             (0x4 for the .xdata section and 0x20 for the
16#             .ctors/.dtors headers/ends).
17# CHECK-NEXT:     VirtualSize: 0x24
18
19# Check that the weak symbols still are emitted as it was when the test was
20# written, to make sure the test still actually tests what was intended.
21
22# SYMBOL:       Symbol {
23# SYMBOL:         Name: foo
24# SYMBOL-NEXT:    Value: 0
25# SYMBOL-NEXT:    Section: IMAGE_SYM_UNDEFINED (0)
26# SYMBOL-NEXT:    BaseType: Null (0x0)
27# SYMBOL-NEXT:    ComplexType: Null (0x0)
28# SYMBOL-NEXT:    StorageClass: WeakExternal (0x69)
29# SYMBOL-NEXT:    AuxSymbolCount: 1
30# SYMBOL-NEXT:    AuxWeakExternal {
31# SYMBOL-NEXT:      Linked: .weak.foo.default.main (19)
32# SYMBOL-NEXT:      Search: Alias (0x3)
33# SYMBOL-NEXT:    }
34# SYMBOL-NEXT:  }
35
36        .text
37        .globl          main
38main:
39        call            foo
40        retq
41
42# See associative-comdat-mingw.s for the general setup. Here, the leader
43# symbols are weak, which causes the functions foo and bar to be undefined
44# weak externals, while the actual leader symbols are named like
45# .weak.foo.default.main.
46
47        .section        .xdata$foo,"dr"
48        .linkonce       discard
49        .long           42
50
51        .section        .xdata$bar,"dr"
52        .linkonce       discard
53        .long           43
54
55        .section        .text$foo,"xr",discard,foo
56        .weak           foo
57foo:
58        ret
59
60        .section        .text$bar,"xr",discard,bar
61        .weak           bar
62bar:
63        ret
64