1# RUN: ld64.lld -arch x86_64 -macosx_version_min 10.8 -dylib \
2# RUN:      %s %p/Inputs/x86_64/libSystem.yaml -o %t \
3# RUN:      -exported_symbols_list %p/Inputs/exported_symbols_list.exp && \
4# RUN: llvm-nm -m %t | FileCheck %s
5#
6# RUN: ld64.lld -arch x86_64 -macosx_version_min 10.8 -dylib \
7# RUN:      %s %p/Inputs/x86_64/libSystem.yaml -o %t2 \
8# RUN:      -exported_symbol _foo -exported_symbol _b  && \
9# RUN: llvm-nm -m %t2 | FileCheck %s
10#
11# RUN: ld64.lld -arch x86_64 -macosx_version_min 10.8 -dylib \
12# RUN:      %s %p/Inputs/x86_64/libSystem.yaml -o %t3 \
13# RUN:      -unexported_symbol _bar -unexported_symbol _a  && \
14# RUN: llvm-nm -m %t3 | FileCheck %s
15#
16# RUN: ld64.lld -arch x86_64 -macosx_version_min 10.8 -dylib \
17# RUN:      %s %p/Inputs/x86_64/libSystem.yaml -dead_strip -o %t \
18# RUN:      -exported_symbols_list %p/Inputs/exported_symbols_list.exp && \
19# RUN: llvm-nm -m %t | FileCheck -check-prefix=CHECK_DEAD %s
20#
21# Test -exported_symbols_list and -exported_symbol properly changes visibility.
22#
23
24--- !mach-o
25arch:            x86_64
26file-type:       MH_OBJECT
27flags:           [ MH_SUBSECTIONS_VIA_SYMBOLS ]
28sections:
29  - segment:         __TEXT
30    section:         __text
31    type:            S_REGULAR
32    attributes:      [ S_ATTR_PURE_INSTRUCTIONS, S_ATTR_SOME_INSTRUCTIONS ]
33    address:         0x0000000000000000
34    content:         [ 0x55, 0x48, 0x89, 0xE5, 0x5D, 0xC3, 0x55, 0x48,
35                       0x89, 0xE5, 0x5D, 0xC3 ]
36  - segment:         __DATA
37    section:         __data
38    type:            S_REGULAR
39    attributes:      [  ]
40    alignment:       2
41    address:         0x000000000000000C
42    content:         [ 0x0A, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00 ]
43
44global-symbols:
45  - name:            _a
46    type:            N_SECT
47    scope:           [ N_EXT ]
48    sect:            2
49    value:           0x000000000000000C
50  - name:            _b
51    type:            N_SECT
52    scope:           [ N_EXT ]
53    sect:            2
54    value:           0x0000000000000010
55  - name:            _bar
56    type:            N_SECT
57    scope:           [ N_EXT ]
58    sect:            1
59    value:           0x0000000000000006
60  - name:            _foo
61    type:            N_SECT
62    scope:           [ N_EXT ]
63    sect:            1
64    value:           0x0000000000000000
65
66
67...
68
69# CHECK: (__DATA,__data) non-external (was a private external) _a
70# CHECK: (__DATA,__data) external _b
71# CHECK: (__TEXT,__text) non-external (was a private external) _bar
72# CHECK: (__TEXT,__text) external _foo
73
74# CHECK_DEAD-NOT:  (__DATA,__data) non-external (was a private external) _a
75# CHECK_DEAD:      (__DATA,__data) external _b
76# CHECK_DEAD-NOT:  (__TEXT,__text) non-external (was a private external) _bar
77# CHECK_DEAD:      (__TEXT,__text) external _foo
78