• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// This tests that default-null weak symbols (a GNU extension) are created
2// properly via the .weak directive.
3
4// RUN: llvm-mc -filetype=obj -triple i686-pc-win32 %s | llvm-readobj -t | FileCheck %s
5// RUN: llvm-mc -filetype=obj -triple x86_64-pc-win32 %s | llvm-readobj -t | FileCheck %s
6
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
25LBB0_2:                                 # %return
26    xorl    %eax, %eax
27    addl    $4, %esp
28    ret
29
30    .weak   _test_weak
31
32    .weak   _test_weak_alias
33    _test_weak_alias=_main
34
35// CHECK: Symbols [
36
37// CHECK:      Symbol {
38// CHECK:        Name:           _test_weak
39// CHECK-NEXT:   Value:          0
40// CHECK-NEXT:   Section:        (0)
41// CHECK-NEXT:   BaseType:       Null
42// CHECK-NEXT:   ComplexType:    Null
43// CHECK-NEXT:   StorageClass:   WeakExternal
44// CHECK-NEXT:   AuxSymbolCount: 1
45// CHECK-NEXT:   AuxWeakExternal {
46// CHECK-NEXT:     Linked: .weak._test_weak.default
47// CHECK-NEXT:      Search: Library
48// CHECK-NEXT:      Unused: (00 00 00 00 00 00 00 00 00 00)
49// CHECK-NEXT:   }
50// CHECK-NEXT: }
51
52// CHECK:      Symbol {
53// CHECK:        Name:                .weak._test_weak.default
54// CHECK-NEXT:   Value:               0
55// CHECK-NEXT:   Section:             (65535)
56// CHECK-NEXT:   BaseType:            Null
57// CHECK-NEXT:   ComplexType:         Null
58// CHECK-NEXT:   StorageClass:        External
59// CHECK-NEXT:   AuxSymbolCount:      0
60// CHECK-NEXT: }
61
62// CHECK:      Symbol {
63// CHECK:        Name:           _test_weak_alias
64// CHECK-NEXT:   Value:          0
65// CHECK-NEXT:   Section:        (0)
66// CHECK-NEXT:   BaseType:       Null
67// CHECK-NEXT:   ComplexType:    Null
68// CHECK-NEXT:   StorageClass:   WeakExternal
69// CHECK-NEXT:   AuxSymbolCount: 1
70// CHECK-NEXT:   AuxWeakExternal {
71// CHECK-NEXT:     Linked: _main
72// CHECK-NEXT:      Search: Library
73// CHECK-NEXT:      Unused: (00 00 00 00 00 00 00 00 00 00)
74// CHECK-NEXT:   }
75// CHECK-NEXT: }
76