|
1 | 1 | # REQUIRES: x86
|
2 |
| -# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o |
3 |
| -# RUN: ld.lld %t.o -o %t --export-dynamic |
4 |
| -# RUN: llvm-readelf -r --hex-dump=.data %t | FileCheck %s --check-prefix=STATIC |
5 |
| -# RUN: ld.lld %t.o -o %t.pie -pie |
6 |
| -# RUN: llvm-readelf -r --hex-dump=.data %t.pie | FileCheck %s --check-prefix=STATIC |
7 |
| -# RUN: ld.lld %t.o -o %t.so -shared |
8 |
| -# RUN: llvm-readobj -r %t.so | FileCheck %s --check-prefix=PIC |
| 2 | +# RUN: rm -rf %t && split-file %s %t && cd %t |
| 3 | +# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o |
| 4 | +# RUN: llvm-mc -filetype=obj -triple=x86_64 b.s -o b.o |
| 5 | +# RUN: llvm-mc -filetype=obj -triple=x86_64 c.s -o c.o |
| 6 | +# RUN: ld.lld a.o -o nopie --export-dynamic |
| 7 | +# RUN: llvm-readelf -r --hex-dump=.data nopie | FileCheck %s --check-prefix=STATIC |
| 8 | +# RUN: ld.lld a.o -o out.pie -pie |
| 9 | +# RUN: llvm-readelf -r --hex-dump=.data out.pie | FileCheck %s --check-prefix=STATIC |
| 10 | +# RUN: ld.lld a.o -o out.so -shared |
| 11 | +# RUN: llvm-readobj -r out.so | FileCheck %s --check-prefix=PIC |
9 | 12 |
|
10 | 13 | ## gABI leaves the behavior of weak undefined references implementation defined.
|
11 | 14 | ## We choose to resolve them statically for static linking and produce dynamic relocations
|
|
23 | 26 | # PIC-NEXT: R_X86_64_64 foobar 0x0
|
24 | 27 | # PIC-NEXT: }
|
25 | 28 |
|
| 29 | +# RUN: ld.lld a.o b.o -o out1 -z undefs |
| 30 | +# RUN: llvm-readelf -r -x .data out1 | FileCheck %s --check-prefix=STATIC1 |
| 31 | +# RUN: ld.lld a.o b.o -o out1.pie -pie -z undefs |
| 32 | +# RUN: llvm-readelf -r -x .data out1.pie | FileCheck %s --check-prefix=STATIC2 |
| 33 | + |
| 34 | +# STATIC1: no relocations |
| 35 | +# STATIC2: R_X86_64_RELATIVE |
| 36 | + |
| 37 | +# RUN: ld.lld a.o b.o c.o -pie -z undefs 2>&1 | count 0 |
| 38 | + |
| 39 | +#--- a.s |
26 | 40 | .global _start
|
27 | 41 | _start:
|
28 | 42 | .data
|
29 | 43 | .weak foobar
|
30 | 44 | .quad foobar
|
| 45 | + |
| 46 | +#--- b.s |
| 47 | +.data |
| 48 | +.quad undef |
| 49 | + |
| 50 | +#--- c.s |
| 51 | +call undef |
0 commit comments