1# REQUIRES: x86
2# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
3
4## We are intentionally building an executable here instead of a dylib / bundle
5## in order that the `__PAGEZERO` segment is present, which in turn means that
6## the image base starts at a non-zero address. This allows us to verify that
7## addresses in the export trie are correctly encoded as relative to the image
8## base.
9# RUN: %lld %t.o -o %t
10
11# RUN: llvm-objdump --syms --exports-trie %t | FileCheck %s --check-prefix=EXPORTS
12# EXPORTS-LABEL: SYMBOL TABLE:
13# EXPORTS-DAG:   [[#%x, MAIN_ADDR:]] {{.*}} _main
14# EXPORTS-DAG:   [[#%x, HELLO_ADDR:]] {{.*}} _hello
15# EXPORTS-DAG:   [[#%x, HELLO_WORLD_ADDR:]] {{.*}} _hello_world
16# EXPORTS-DAG:   [[#%x, HELLO_ITS_ME_ADDR:]] {{.*}} _hello_its_me
17# EXPORTS-DAG:   [[#%x, HELLO_ITS_YOU_ADDR:]] {{.*}} _hello_its_you
18# EXPORTS-DAG:   [[#%x, HEADER_ADDR:]] g F __TEXT,__text __mh_execute_header
19# EXPORTS-LABEL: Exports trie:
20# EXPORTS-DAG:   0x{{0*}}[[#%X, HEADER_ADDR]] __mh_execute_header
21# EXPORTS-DAG:   0x{{0*}}[[#%X, MAIN_ADDR]] _main
22# EXPORTS-DAG:   0x{{0*}}[[#%X, HELLO_ADDR]] _hello
23# EXPORTS-DAG:   0x{{0*}}[[#%X, HELLO_WORLD_ADDR]] _hello_world
24# EXPORTS-DAG:   0x{{0*}}[[#%x, HELLO_ITS_ME_ADDR:]] _hello_its_me
25# EXPORTS-DAG:   0x{{0*}}[[#%x, HELLO_ITS_YOU_ADDR:]] _hello_its_you
26
27## Check that we are sharing prefixes in the trie.
28# RUN: obj2yaml %t | FileCheck %s
29# CHECK-LABEL: ExportTrie:
30# CHECK: Name: ''
31# CHECK: Name: _
32# CHECK-DAG: Name: _mh_execute_header
33# CHECK-DAG: Name: main
34# CHECK-DAG: Name: hello
35# CHECK: Name: _
36# CHECK: Name: world
37# CHECK: Name: its_
38# CHECK-DAG: Name: you
39# CHECK-DAG: Name: me
40
41
42
43.section __TEXT,__cstring
44.globl _hello, _hello_world, _hello_its_me, _hello_its_you, _main
45
46## Test for when an entire symbol name is a prefix of another.
47_hello:
48.asciz "Hello!\n"
49
50_hello_world:
51.asciz "Hello world!\n"
52
53.data
54_hello_its_me:
55.asciz "Hello, it's me\n"
56
57_hello_its_you:
58.asciz "Hello, it's you\n"
59
60_main:
61  ret
62