gn build: Merge r374476
[llvm-complete.git] / test / MC / COFF / weak.s
blob5e216cef2cbd0f9ef291506726d8ba97d73f33c1
1 // This tests that default-null weak symbols (a GNU extension) are created
2 // properly via the .weak directive.
4 // RUN: llvm-mc -filetype=obj -triple i686-pc-win32 %s | llvm-readobj --symbols | FileCheck %s
5 // RUN: llvm-mc -filetype=obj -triple x86_64-pc-win32 %s | llvm-readobj --symbols | FileCheck %s
7 .def _main;
8 .scl 2;
9 .type 32;
10 .endef
11 .text
12 .globl _main
13 .align 16, 0x90
14 _main: # @main
15 # %bb.0: # %entry
16 subl $4, %esp
17 movl $_test_weak, %eax
18 testl %eax, %eax
19 je LBB0_2
20 # %bb.1: # %if.then
21 call _test_weak
22 movl $1, %eax
23 addl $4, %esp
24 ret
25 LBB0_2: # %return
26 xorl %eax, %eax
27 addl $4, %esp
28 ret
30 .weak _test_weak
32 .weak _test_weak_alias
33 _test_weak_alias=_main
35 // CHECK: Symbols [
37 // CHECK: Symbol {
38 // CHECK: Name: _main
39 // CHECK-NEXT: Value: 0
40 // CHECK-NEXT: Section: .text
41 // CHECK-NEXT: BaseType: Null
42 // CHECK-NEXT: ComplexType: Function
43 // CHECK-NEXT: StorageClass: External
44 // CHECK-NEXT: AuxSymbolCount: 0
45 // CHECK-NEXT: }
47 // CHECK: Symbol {
48 // CHECK: Name: _test_weak
49 // CHECK-NEXT: Value: 0
50 // CHECK-NEXT: Section: IMAGE_SYM_UNDEFINED (0)
51 // CHECK-NEXT: BaseType: Null
52 // CHECK-NEXT: ComplexType: Null
53 // CHECK-NEXT: StorageClass: WeakExternal
54 // CHECK-NEXT: AuxSymbolCount: 1
55 // CHECK-NEXT: AuxWeakExternal {
56 // CHECK-NEXT: Linked: .weak._test_weak.default
57 // CHECK-NEXT: Search: Alias
58 // CHECK-NEXT: }
59 // CHECK-NEXT: }
61 // CHECK: Symbol {
62 // CHECK: Name: .weak._test_weak.default
63 // CHECK-NEXT: Value: 0
64 // CHECK-NEXT: Section: IMAGE_SYM_ABSOLUTE (-1)
65 // CHECK-NEXT: BaseType: Null
66 // CHECK-NEXT: ComplexType: Null
67 // CHECK-NEXT: StorageClass: External
68 // CHECK-NEXT: AuxSymbolCount: 0
69 // CHECK-NEXT: }
71 // CHECK: Symbol {
72 // CHECK: Name: _test_weak_alias
73 // CHECK-NEXT: Value: 0
74 // CHECK-NEXT: Section: IMAGE_SYM_UNDEFINED (0)
75 // CHECK-NEXT: BaseType: Null
76 // CHECK-NEXT: ComplexType: Null
77 // CHECK-NEXT: StorageClass: WeakExternal
78 // CHECK-NEXT: AuxSymbolCount: 1
79 // CHECK-NEXT: AuxWeakExternal {
80 // CHECK-NEXT: Linked: .weak._test_weak_alias.default
81 // CHECK-NEXT: Search: Alias
82 // CHECK-NEXT: }
83 // CHECK-NEXT: }
85 // CHECK: Symbol {
86 // CHECK: Name: .weak._test_weak_alias.default
87 // CHECK-NEXT: Value: 0
88 // CHECK-NEXT: Section: .text
89 // CHECK-NEXT: BaseType: Null
90 // CHECK-NEXT: ComplexType: Null
91 // CHECK-NEXT: StorageClass: External
92 // CHECK-NEXT: AuxSymbolCount: 0
93 // CHECK-NEXT: }