Skip to content

Commit 345f532

Browse files
committed
[ELF][test] Improve relocations referencing STT_SECTION tests for -r
Also add a --compress-debug-sections=zlib test to demonstrate issue llvm#66738
1 parent 33df617 commit 345f532

File tree

2 files changed

+68
-53
lines changed

2 files changed

+68
-53
lines changed

lld/test/ELF/pr37735.s

Lines changed: 0 additions & 12 deletions
This file was deleted.
Lines changed: 68 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,77 @@
1-
# REQUIRES: x86
2-
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
1+
# REQUIRES: x86, zlib
2+
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
33
# RUN: ld.lld -r -o %t %t.o %t.o
4-
# RUN: llvm-readobj -r %t | FileCheck --check-prefix=RELA %s
4+
# RUN: llvm-readelf -r -x .data -x .bar -x .debug_line %t | FileCheck --check-prefix=RELA %s
55

6-
# RELA: Relocations [
7-
# RELA-NEXT: Section ({{.*}}) .rela.data {
8-
# RELA-NEXT: 0x0 R_X86_64_32 .text 0x1
9-
# RELA-NEXT: 0x4 R_X86_64_32 .text 0x5
10-
# RELA-NEXT: }
11-
# RELA-NEXT: ]
6+
# RELA: Offset Info Type Symbol's Value Symbol's Name + Addend
7+
# RELA-NEXT: 0000000000000000 {{.*}} R_X86_64_32 0000000000000000 .text + 1
8+
# RELA-NEXT: 0000000000000004 {{.*}} R_X86_64_32 0000000000000000 .text + 5
9+
# RELA-EMPTY:
10+
# RELA: Offset Info Type Symbol's Value Symbol's Name + Addend
11+
# RELA-NEXT: 0000000000000000 {{.*}} R_X86_64_64 0000000000000000 .foo + 1
12+
# RELA-NEXT: 0000000000000008 {{.*}} R_X86_64_32 0000000000000000 .text + 0
13+
# RELA-NEXT: 000000000000000c {{.*}} R_X86_64_64 0000000000000000 .foo + 2
14+
# RELA-NEXT: 0000000000000014 {{.*}} R_X86_64_32 0000000000000000 .text + 4
15+
# RELA-EMPTY:
16+
# RELA: Offset Info Type Symbol's Value Symbol's Name + Addend
17+
# RELA-NEXT: 0000000000000000 {{.*}} R_X86_64_64 0000000000000000 .foo + 1
18+
# RELA-NEXT: 0000000000000008 {{.*}} R_X86_64_32 0000000000000000 .text + 0
19+
# RELA-NEXT: 000000000000000c {{.*}} R_X86_64_64 0000000000000000 .foo + 2
20+
# RELA-NEXT: 0000000000000014 {{.*}} R_X86_64_32 0000000000000000 .text + 4
1221

22+
# RELA: Hex dump of section '.data':
23+
# RELA-NEXT: 0x00000000 00000000 00000000 ........
24+
# RELA: Hex dump of section '.bar':
25+
# RELA-NEXT: 0x00000000 00000000 00000000 00000000 00000000 ................
26+
# RELA-NEXT: 0x00000010 00000000 00000000 ........
27+
# RELA: Hex dump of section '.debug_line':
28+
# RELA-NEXT: 0x00000000 00000000 00000000 00000000 00000000 ................
29+
# RELA-NEXT: 0x00000010 00000000 00000000 ........
1330

14-
# RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o
15-
# RUN: ld.lld -r -o %t %t.o %t.o
16-
# RUN: llvm-readobj -r -S --section-data %t | FileCheck --check-prefix=REL %s
17-
18-
19-
# REL: Section {
20-
# REL: Index:
21-
# REL: Name: .data
22-
# REL-NEXT: Type: SHT_PROGBITS
23-
# REL-NEXT: Flags [
24-
# REL-NEXT: SHF_ALLOC
25-
# REL-NEXT: SHF_WRITE
26-
# REL-NEXT: ]
27-
# REL-NEXT: Address:
28-
# REL-NEXT: Offset:
29-
# REL-NEXT: Size:
30-
# REL-NEXT: Link:
31-
# REL-NEXT: Info:
32-
# REL-NEXT: AddressAlignment:
33-
# REL-NEXT: EntrySize:
34-
# REL-NEXT: SectionData (
35-
# REL-NEXT: 0000: 01000000 05000000 |
36-
# REL-NEXT: )
37-
# REL-NEXT: }
38-
39-
40-
# REL: Relocations [
41-
# REL-NEXT: Section ({{.*}}) .rel.data {
42-
# REL-NEXT: 0x0 R_386_32 .text
43-
# REL-NEXT: 0x4 R_386_32 .text
44-
# REL-NEXT: }
45-
# REL-NEXT: ]
31+
# RUN: llvm-mc -filetype=obj -triple=i686 %s -o %t1.o
32+
# RUN: ld.lld -r -o %t1 %t1.o %t1.o
33+
# RUN: llvm-readelf -r -x .data -x .bar -x .debug_line %t1 | FileCheck %s --check-prefixes=REL,REL0
34+
# RUN: ld.lld -r --compress-debug-sections=zlib -o %t1.zlib %t1.o %t1.o
35+
# RUN: llvm-objcopy --decompress-debug-sections %t1.zlib %t1.zlib.de
36+
# RUN: llvm-readelf -r -x .data -x .bar -x .debug_line %t1.zlib.de | FileCheck %s --check-prefixes=REL,REL1
37+
38+
# REL: Offset Info Type Sym. Value Symbol's Name
39+
# REL-NEXT: 00000000 {{.*}} R_386_32 00000000 .text
40+
# REL-NEXT: 00000004 {{.*}} R_386_32 00000000 .text
41+
# REL-EMPTY:
42+
# REL: Offset Info Type Sym. Value Symbol's Name
43+
# REL-NEXT: 00000000 {{.*}} R_386_32 00000000 .foo
44+
# REL-NEXT: 00000004 {{.*}} R_386_32 00000000 .text
45+
# REL-NEXT: 00000008 {{.*}} R_386_32 00000000 .foo
46+
# REL-NEXT: 0000000c {{.*}} R_386_32 00000000 .text
47+
# REL-EMPTY:
48+
# REL: Offset Info Type Sym. Value Symbol's Name
49+
# REL-NEXT: 00000000 {{.*}} R_386_32 00000000 .foo
50+
# REL-NEXT: 00000004 {{.*}} R_386_32 00000000 .text
51+
# REL-NEXT: 00000008 {{.*}} R_386_32 00000000 .foo
52+
# REL-NEXT: 0000000c {{.*}} R_386_32 00000000 .text
4653

54+
# REL: Hex dump of section '.data':
55+
# REL-NEXT: 0x00000000 01000000 05000000 ........
56+
# REL: Hex dump of section '.bar':
57+
# REL-NEXT: 0x00000000 01000000 00000000 02000000 04000000 ................
58+
# REL0: Hex dump of section '.debug_line':
59+
# REL0-NEXT: 0x00000000 01000000 00000000 02000000 04000000 ................
60+
## FIXME: https://github.com/llvm/llvm-project/issues/66738 The implicit addends for the second input section are wrong.
61+
# REL1: Hex dump of section '.debug_line':
62+
# REL1-NEXT: 0x00000000 01000000 00000000 01000000 00000000 ................
4763

4864
.long 42
4965
.data
5066
.long .text + 1
67+
68+
.section .foo
69+
.byte 0
70+
71+
.section .bar
72+
.dc.a .foo + 1
73+
.dc.l .text
74+
75+
.section .debug_line
76+
.dc.a .foo + 1
77+
.dc.l .text

0 commit comments

Comments
 (0)