2020-05-15 03:43:51 +08:00
|
|
|
# REQUIRES: x86
|
2020-12-22 03:43:58 +08:00
|
|
|
# RUN: rm -rf %t; split-file %s %t
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/2.s -o %t/2.o
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/3.s -o %t/3.o
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/4.s -o %t/4.o
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/main.s -o %t/main.o
|
2020-05-15 03:43:51 +08:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2021-06-19 10:30:57 +08:00
|
|
|
## Multiple archives defining the same symbols aren't an issue, due to lazy
|
|
|
|
## loading
|
|
|
|
# RUN: cp %t/test.a %t/test2.a
|
|
|
|
# RUN: %lld %t/test.a %t/test2.a %t/main.o -o /dev/null
|
|
|
|
|
2020-12-22 03:43:58 +08:00
|
|
|
#--- 2.s
|
|
|
|
.globl _boo
|
|
|
|
_boo:
|
|
|
|
ret
|
|
|
|
|
|
|
|
#--- 3.s
|
|
|
|
.globl _bar
|
|
|
|
_bar:
|
|
|
|
ret
|
|
|
|
|
|
|
|
#--- 4.s
|
|
|
|
.globl _undefined, _unused
|
|
|
|
_unused:
|
|
|
|
ret
|
|
|
|
|
|
|
|
#--- main.s
|
|
|
|
.globl _main
|
2020-05-15 03:43:51 +08:00
|
|
|
_main:
|
|
|
|
callq _boo
|
|
|
|
callq _bar
|
|
|
|
ret
|