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