2020-05-15 03:43:51 +08:00
|
|
|
# REQUIRES: x86
|
|
|
|
# RUN: mkdir -p %t
|
|
|
|
# RUN: echo ".global _boo; _boo: ret" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/2.o
|
|
|
|
# RUN: echo ".global _bar; _bar: ret" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/3.o
|
|
|
|
# RUN: echo ".global _undefined; .global _unused; _unused: ret" | llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/4.o
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/main.o
|
|
|
|
|
|
|
|
# RUN: rm -f %t/test.a
|
|
|
|
# RUN: llvm-ar rcs %t/test.a %t/2.o %t/3.o %t/4.o
|
2020-09-19 12:40:12 +08:00
|
|
|
# RUN: %lld %t/main.o %t/test.a -o %t/test.out
|
2020-05-15 03:43:51 +08:00
|
|
|
|
|
|
|
## TODO: Run llvm-nm -p to validate symbol order
|
|
|
|
# RUN: llvm-nm %t/test.out | FileCheck %s
|
|
|
|
# CHECK: T _bar
|
|
|
|
# CHECK: T _boo
|
|
|
|
# CHECK: T _main
|
|
|
|
|
|
|
|
## Linking with the archive first in the command line shouldn't change anything
|
2020-09-19 12:40:12 +08:00
|
|
|
# RUN: %lld %t/test.a %t/main.o -o %t/test.out
|
2020-05-15 03:43:51 +08:00
|
|
|
# RUN: llvm-nm %t/test.out | FileCheck %s --check-prefix ARCHIVE-FIRST
|
|
|
|
# ARCHIVE-FIRST: T _bar
|
|
|
|
# ARCHIVE-FIRST: T _boo
|
|
|
|
# ARCHIVE-FIRST: T _main
|
|
|
|
|
|
|
|
# RUN: llvm-nm %t/test.out | FileCheck %s --check-prefix VISIBLE
|
|
|
|
# VISIBLE-NOT: T _undefined
|
|
|
|
# VISIBLE-NOT: T _unused
|
|
|
|
|
2020-09-19 12:40:12 +08:00
|
|
|
# RUN: %lld %t/test.a %t/main.o -o %t/all-load -all_load
|
2020-08-26 11:00:42 +08:00
|
|
|
# RUN: llvm-nm %t/all-load | FileCheck %s --check-prefix ALL-LOAD
|
|
|
|
# ALL-LOAD: T _bar
|
|
|
|
# ALL-LOAD: T _boo
|
|
|
|
# ALL-LOAD: T _main
|
|
|
|
# ALL-LOAD: T _unused
|
|
|
|
|
2020-05-15 03:43:51 +08:00
|
|
|
.global _main
|
|
|
|
_main:
|
|
|
|
callq _boo
|
|
|
|
callq _bar
|
|
|
|
mov $0, %rax
|
|
|
|
ret
|