xref: /llvm-project/llvm/test/ExecutionEngine/JITLink/x86-64/MachO_cstring_section_splitting.s (revision bfb0a518e73623732c6567916d066df817e0cb0c)
1# REQUIRES: asserts
2# RUN: llvm-mc -triple=x86_64-apple-macosx10.9 -filetype=obj -o %t %s
3# RUN: llvm-jitlink -num-threads=0 -debug-only=jitlink -noexec \
4# RUN:              -entry hook %t 2>&1 \
5# RUN:              | FileCheck %s
6#
7# Verify that we split C string literals on null-terminators, rather than on
8# symbol boundaries. We expect four dead-stripped symbols: l_str.0, l_str.2,
9# L_str.3, l_str.4, and the auto-generated symbol for the start of the "defghi"
10# string. We also verify that there are only two dead-stripped blocks, since
11# l_str.3 should not have split the block started at "def"... (since this is a
12# C string section we should be splitting on null characters instead of
13# symbols).
14#
15# CHECK:      Dead-stripping defined symbols:
16# CHECK-NEXT: linkage: strong, scope: local, dead
17# CHECK-NEXT: linkage: strong, scope: local, dead
18# CHECK-NEXT: linkage: strong, scope: local, dead
19# CHECK-NEXT: linkage: strong, scope: local, dead
20# CHECK-NEXT: Dead-stripping blocks:
21# CHECK-NEXT: content, align = 1, align-ofs = 0, section = __TEXT,__cstring
22# CHECK-NEXT: content, align = 1, align-ofs = 0, section = __TEXT,__cstring
23# CHECK-NEXT: Removing unused external symbols
24
25        .section        __DATA,__data
26        .globl  hook
27        .p2align        2
28hook:
29        .quad   l_str.1
30
31        .section        __TEXT,__cstring,cstring_literals
32l_str.0:
33l_str.1:
34        .asciz  "abc"
35l_str.2:
36        .asciz  ""
37# anonymous start for "defghi", split in the middle by l_str.3. We expect this
38# to be dead-stripped as a single block.
39        .byte   'd'
40        .byte   'e'
41        .byte   'f'
42l_str.3:
43        .asciz  "ghi"
44
45.subsections_via_symbols
46