Skip to content

Commit f8ffbae

Browse files
committed
[test] Test absolute/relative relocations referencing undefined non-weak symbol
1 parent 539ef5e commit f8ffbae

File tree

1 file changed

+28
-7
lines changed

1 file changed

+28
-7
lines changed

lld/test/ELF/weak-undef-rw.s

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
# 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
912

1013
## gABI leaves the behavior of weak undefined references implementation defined.
1114
## We choose to resolve them statically for static linking and produce dynamic relocations
@@ -23,8 +26,26 @@
2326
# PIC-NEXT: R_X86_64_64 foobar 0x0
2427
# PIC-NEXT: }
2528

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
2640
.global _start
2741
_start:
2842
.data
2943
.weak foobar
3044
.quad foobar
45+
46+
#--- b.s
47+
.data
48+
.quad undef
49+
50+
#--- c.s
51+
call undef

0 commit comments

Comments
 (0)