Skip to content

Commit d8118ed

Browse files
committed
[ELF,test] Improve weak-undef-rw.s
1 parent faa49d6 commit d8118ed

File tree

1 file changed

+34
-20
lines changed

1 file changed

+34
-20
lines changed

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

Lines changed: 34 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@
33
# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o
44
# RUN: llvm-mc -filetype=obj -triple=x86_64 b.s -o b.o
55
# 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
6+
# RUN: llvm-mc -filetype=obj -triple=x86_64 %S/Inputs/shared.s -o s.o
7+
# RUN: ld.lld -shared s.o -o s.so
8+
9+
# RUN: ld.lld a.o -o a --export-dynamic
10+
# RUN: llvm-readelf -r --hex-dump=.data a | FileCheck %s --check-prefix=STATIC
11+
# RUN: ld.lld a.o s.so -o as
12+
# RUN: llvm-readelf -r --hex-dump=.data as | FileCheck %s --check-prefix=STATIC
13+
# RUN: ld.lld a.o -o a.pie -pie
14+
# RUN: llvm-readelf -r --hex-dump=.data a.pie | FileCheck %s --check-prefix=STATIC
15+
# RUN: ld.lld a.o -o a.so -shared
16+
# RUN: llvm-readelf -r a.so | FileCheck %s --check-prefix=DYN
1217

1318
## gABI leaves the behavior of weak undefined references implementation defined.
1419
## We choose to resolve them statically for static linking and produce dynamic relocations
@@ -19,35 +24,44 @@
1924

2025
# STATIC: no relocations
2126
# STATIC: Hex dump of section '.data':
22-
# STATIC-NEXT: {{.*}} 00000000 00000000 .
27+
# STATIC-NEXT: {{.*}} 00000000 00000000 03000000 00000000 .
2328
# STATIC-EMPTY:
2429

25-
# PIC: .rela.dyn {
26-
# PIC-NEXT: R_X86_64_64 foobar 0x0
27-
# PIC-NEXT: }
30+
# DYN: Relocation section '.rela.dyn' {{.*}} contains 2
31+
# DYN: R_X86_64_64 0000000000000000 foobar + 0{{$}}
2832

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=STATIC1
33+
# RUN: ld.lld a.o b.o -o ab -z undefs
34+
# RUN: llvm-readelf -r -x .data ab | FileCheck %s --check-prefix=STATIC1
35+
# RUN: ld.lld a.o b.o s.so -o abs -z undefs
36+
# RUN: llvm-readelf -r -x .data abs | FileCheck %s --check-prefix=DYN1
37+
# RUN: ld.lld a.o b.o -o abs.pie -pie -z undefs
38+
# RUN: llvm-readelf -r -x .data abs.pie | FileCheck %s --check-prefix=STATIC1
3339

3440
# STATIC1: no relocations
3541
# STATIC1: Hex dump of section '.data':
36-
# STATIC1-NEXT: {{.*}} 00000000 00000000 00000000 00000000 .
42+
# STATIC1-NEXT: {{.*}} 00000000 00000000 03000000 00000000 .
43+
# STATIC1-NEXT: {{.*}} 05000000 00000000 .
3744
# STATIC1-EMPTY:
3845

46+
# DYN1: Relocation section '.rela.dyn' {{.*}} contains 1
47+
# DYN1: Hex dump of section '.data':
48+
# DYN1-NEXT: {{.*}} 00000000 00000000 03000000 00000000 .
49+
# DYN1-NEXT: {{.*}} 00000000 00000000 .
50+
# DYN1-EMPTY:
51+
3952
# RUN: ld.lld a.o b.o c.o -pie -z undefs 2>&1 | count 0
4053

4154
#--- a.s
42-
.global _start
55+
.global _start
4356
_start:
44-
.data
45-
.weak foobar
46-
.quad foobar
57+
.data
58+
.weak foobar
59+
.quad foobar
60+
.quad foobar+3
4761

4862
#--- b.s
4963
.data
50-
.quad undef
64+
.quad undef+5
5165

5266
#--- c.s
5367
call undef

0 commit comments

Comments
 (0)