llvm-project
44 строки · 1.5 Кб
1# REQUIRES: x86
2# RUN: rm -rf %t; split-file %s %t
3
4# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/foo.o %t/foo.s
5# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/main.o %t/main.s
6
7# RUN: %lld -alias _foo _bar -u _bar -exported_symbol _bar %t/main.o %t/foo.o -o %t/bar.o
8# RUN: llvm-nm %t/bar.o | FileCheck %s --check-prefix=BAR
9
10# BAR: [[#%x,FOO_ADDR:]] T _bar
11# BAR: [[#FOO_ADDR]] t _foo
12
13# RUN: not %lld -alias _missing _bar -alias _missing2 _baz %t/main.o -o %t/missing.o %s 2>&1 | FileCheck %s --check-prefix=MISSING
14
15# MISSING-DAG: undefined base symbol '_missing' for alias '_bar'
16# MISSING-DAG: undefined base symbol '_missing2' for alias '_baz'
17
18# RUN: %lld -alias _foo _main %t/foo.o -o %t/main_rename.o
19# RUN: llvm-nm %t/main_rename.o | FileCheck %s --check-prefix=MAIN
20
21# MAIN: [[#%x,FOO_ADDR:]] T _foo
22# MAIN: [[#FOO_ADDR]] T _main
23
24## Verify dead stripping doesn't remove the aliased symbol. This behavior differs
25## from ld64 where it actually does dead strip only the alias, not the original symbol.
26# RUN: %lld -dead_strip -alias _foo _bar -alias _main _fake_main %t/main.o %t/foo.o -o %t/multiple.o
27# RUN: llvm-nm %t/multiple.o | FileCheck %s --check-prefix=MULTIPLE
28
29# MULTIPLE: [[#%x,FOO_ADDR:]] T _bar
30# MULTIPLE: [[#%x,MAIN_ADDR:]] T _fake_main
31# MULTIPLE: [[#FOO_ADDR]] T _foo
32# MULTIPLE: [[#MAIN_ADDR]] T _main
33
34#--- foo.s
35.subsections_via_symbols
36.globl _foo
37_foo:
38ret
39
40#--- main.s
41.subsections_via_symbols
42.globl _main
43_main:
44ret
45