Skip to content

Commit

Permalink
[test][lld][ELF] Enhance pack-dyn-relocs.s test (#87756)
Browse files Browse the repository at this point in the history
Use symbol `.data` (STT_SECTION) instead of `__ehdr_start` for some
relocation entries. See discussion in

[72714/#discussion_r1517127619](#72714)
  • Loading branch information
kovdan01 authored Apr 5, 2024
1 parent 0a0fccf commit 3989e22
Showing 1 changed file with 50 additions and 50 deletions.
100 changes: 50 additions & 50 deletions lld/test/ELF/pack-dyn-relocs.s
Original file line number Diff line number Diff line change
Expand Up @@ -198,34 +198,34 @@
// RUN: llvm-readobj -r %t2.a64 | FileCheck --check-prefix=UNPACKED64 %s

// UNPACKED64: Section ({{.+}}) .rela.dyn {
// UNPACKED64-NEXT: 0x30690 R_AARCH64_RELATIVE - 0x0
// UNPACKED64-NEXT: 0x30698 R_AARCH64_RELATIVE - 0x1
// UNPACKED64-NEXT: 0x30690 R_AARCH64_RELATIVE - 0x30690
// UNPACKED64-NEXT: 0x30698 R_AARCH64_RELATIVE - 0x30691
// UNPACKED64-NEXT: 0x306A0 R_AARCH64_RELATIVE - 0x2
// UNPACKED64-NEXT: 0x306A8 R_AARCH64_RELATIVE - 0xFFFFFFFFFFFFFFFF
// UNPACKED64-NEXT: 0x306B0 R_AARCH64_RELATIVE - 0x80000000
// UNPACKED64-NEXT: 0x306B8 R_AARCH64_RELATIVE - 0x6
// UNPACKED64-NEXT: 0x306C0 R_AARCH64_RELATIVE - 0x7
// UNPACKED64-NEXT: 0x306C8 R_AARCH64_RELATIVE - 0x8
// UNPACKED64-NEXT: 0x306C8 R_AARCH64_RELATIVE - 0x30698

// UNPACKED64-NEXT: 0x306D8 R_AARCH64_RELATIVE - 0x1
// UNPACKED64-NEXT: 0x306D8 R_AARCH64_RELATIVE - 0x30691
// UNPACKED64-NEXT: 0x306E0 R_AARCH64_RELATIVE - 0x2
// UNPACKED64-NEXT: 0x306E8 R_AARCH64_RELATIVE - 0x3
// UNPACKED64-NEXT: 0x306F0 R_AARCH64_RELATIVE - 0x4
// UNPACKED64-NEXT: 0x306F8 R_AARCH64_RELATIVE - 0x5
// UNPACKED64-NEXT: 0x30700 R_AARCH64_RELATIVE - 0x6
// UNPACKED64-NEXT: 0x30708 R_AARCH64_RELATIVE - 0x7
// UNPACKED64-NEXT: 0x30708 R_AARCH64_RELATIVE - 0x30697

// UNPACKED64-NEXT: 0x30720 R_AARCH64_RELATIVE - 0x1
// UNPACKED64-NEXT: 0x30720 R_AARCH64_RELATIVE - 0x30691
// UNPACKED64-NEXT: 0x30728 R_AARCH64_RELATIVE - 0x2
// UNPACKED64-NEXT: 0x30730 R_AARCH64_RELATIVE - 0x3
// UNPACKED64-NEXT: 0x30738 R_AARCH64_RELATIVE - 0x4
// UNPACKED64-NEXT: 0x30740 R_AARCH64_RELATIVE - 0x5
// UNPACKED64-NEXT: 0x30748 R_AARCH64_RELATIVE - 0x6
// UNPACKED64-NEXT: 0x30750 R_AARCH64_RELATIVE - 0x7
// UNPACKED64-NEXT: 0x30758 R_AARCH64_RELATIVE - 0x8
// UNPACKED64-NEXT: 0x30760 R_AARCH64_RELATIVE - 0x9
// UNPACKED64-NEXT: 0x30760 R_AARCH64_RELATIVE - 0x30699

// UNPACKED64-NEXT: 0x30769 R_AARCH64_RELATIVE - 0xA
// UNPACKED64-NEXT: 0x30769 R_AARCH64_RELATIVE - 0x3069A

// UNPACKED64-NEXT: 0x306D0 R_AARCH64_ABS64 bar2 0x1
// UNPACKED64-NEXT: 0x30718 R_AARCH64_ABS64 bar2 0x0
Expand All @@ -247,47 +247,47 @@

// ANDROID64: (DEBUG) 0x0
// ANDROID64-NEXT: (ANDROID_RELA) 0x[[#ANDROID]]
// ANDROID64-NEXT: (ANDROID_RELASZ) 122 (bytes)
// ANDROID64-NEXT: (ANDROID_RELASZ) 136 (bytes)
// ANDROID64-NEXT: (RELAENT) 24 (bytes)

// ANDROID64-HEADERS: 0x0000000060000011 ANDROID_RELA [[ADDR]]
// ANDROID64-HEADERS: 0x0000000060000012 ANDROID_RELASZ [[SIZE]]

// ANDROID64: Relocation section '.rela.dyn' at offset {{.*}} contains 33 entries:
// ANDROID64-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
// ANDROID64-NEXT: 00000000000303e8 0000000000000403 R_AARCH64_RELATIVE 0
// ANDROID64-NEXT: 00000000000303f0 0000000000000403 R_AARCH64_RELATIVE 1
// ANDROID64-NEXT: 00000000000303f8 0000000000000403 R_AARCH64_RELATIVE 2
// ANDROID64-NEXT: 0000000000030400 0000000000000403 R_AARCH64_RELATIVE ffffffffffffffff
// ANDROID64-NEXT: 0000000000030408 0000000000000403 R_AARCH64_RELATIVE 80000000
// ANDROID64-NEXT: 0000000000030410 0000000000000403 R_AARCH64_RELATIVE 6
// ANDROID64-NEXT: 0000000000030418 0000000000000403 R_AARCH64_RELATIVE 7
// ANDROID64-NEXT: 0000000000030420 0000000000000403 R_AARCH64_RELATIVE 8
// ANDROID64-NEXT: 0000000000030478 0000000000000403 R_AARCH64_RELATIVE 1
// ANDROID64-NEXT: 0000000000030480 0000000000000403 R_AARCH64_RELATIVE 2
// ANDROID64-NEXT: 0000000000030488 0000000000000403 R_AARCH64_RELATIVE 3
// ANDROID64-NEXT: 0000000000030490 0000000000000403 R_AARCH64_RELATIVE 4
// ANDROID64-NEXT: 0000000000030498 0000000000000403 R_AARCH64_RELATIVE 5
// ANDROID64-NEXT: 00000000000304a0 0000000000000403 R_AARCH64_RELATIVE 6
// ANDROID64-NEXT: 00000000000304a8 0000000000000403 R_AARCH64_RELATIVE 7
// ANDROID64-NEXT: 00000000000304b0 0000000000000403 R_AARCH64_RELATIVE 8
// ANDROID64-NEXT: 00000000000304b8 0000000000000403 R_AARCH64_RELATIVE 9
// ANDROID64-NEXT: 0000000000030430 0000000000000403 R_AARCH64_RELATIVE 1
// ANDROID64-NEXT: 0000000000030438 0000000000000403 R_AARCH64_RELATIVE 2
// ANDROID64-NEXT: 0000000000030440 0000000000000403 R_AARCH64_RELATIVE 3
// ANDROID64-NEXT: 0000000000030448 0000000000000403 R_AARCH64_RELATIVE 4
// ANDROID64-NEXT: 0000000000030450 0000000000000403 R_AARCH64_RELATIVE 5
// ANDROID64-NEXT: 0000000000030458 0000000000000403 R_AARCH64_RELATIVE 6
// ANDROID64-NEXT: 0000000000030460 0000000000000403 R_AARCH64_RELATIVE 7
// ANDROID64-NEXT: 00000000000304c1 0000000000000403 R_AARCH64_RELATIVE a
// ANDROID64-NEXT: 0000000000030470 0000000100000101 R_AARCH64_ABS64 0000000000000000 bar2 + 0
// ANDROID64-NEXT: 00000000000304c9 0000000100000101 R_AARCH64_ABS64 0000000000000000 bar2 + 0
// ANDROID64-NEXT: 00000000000303f0 0000000000000403 R_AARCH64_RELATIVE 303f0
// ANDROID64-NEXT: 00000000000303f8 0000000000000403 R_AARCH64_RELATIVE 303f1
// ANDROID64-NEXT: 0000000000030400 0000000000000403 R_AARCH64_RELATIVE 2
// ANDROID64-NEXT: 0000000000030408 0000000000000403 R_AARCH64_RELATIVE ffffffffffffffff
// ANDROID64-NEXT: 0000000000030410 0000000000000403 R_AARCH64_RELATIVE 80000000
// ANDROID64-NEXT: 0000000000030418 0000000000000403 R_AARCH64_RELATIVE 6
// ANDROID64-NEXT: 0000000000030420 0000000000000403 R_AARCH64_RELATIVE 7
// ANDROID64-NEXT: 0000000000030428 0000000000000403 R_AARCH64_RELATIVE 303f8
// ANDROID64-NEXT: 0000000000030480 0000000000000403 R_AARCH64_RELATIVE 303f1
// ANDROID64-NEXT: 0000000000030488 0000000000000403 R_AARCH64_RELATIVE 2
// ANDROID64-NEXT: 0000000000030490 0000000000000403 R_AARCH64_RELATIVE 3
// ANDROID64-NEXT: 0000000000030498 0000000000000403 R_AARCH64_RELATIVE 4
// ANDROID64-NEXT: 00000000000304a0 0000000000000403 R_AARCH64_RELATIVE 5
// ANDROID64-NEXT: 00000000000304a8 0000000000000403 R_AARCH64_RELATIVE 6
// ANDROID64-NEXT: 00000000000304b0 0000000000000403 R_AARCH64_RELATIVE 7
// ANDROID64-NEXT: 00000000000304b8 0000000000000403 R_AARCH64_RELATIVE 8
// ANDROID64-NEXT: 00000000000304c0 0000000000000403 R_AARCH64_RELATIVE 303f9
// ANDROID64-NEXT: 0000000000030438 0000000000000403 R_AARCH64_RELATIVE 303f1
// ANDROID64-NEXT: 0000000000030440 0000000000000403 R_AARCH64_RELATIVE 2
// ANDROID64-NEXT: 0000000000030448 0000000000000403 R_AARCH64_RELATIVE 3
// ANDROID64-NEXT: 0000000000030450 0000000000000403 R_AARCH64_RELATIVE 4
// ANDROID64-NEXT: 0000000000030458 0000000000000403 R_AARCH64_RELATIVE 5
// ANDROID64-NEXT: 0000000000030460 0000000000000403 R_AARCH64_RELATIVE 6
// ANDROID64-NEXT: 0000000000030468 0000000000000403 R_AARCH64_RELATIVE 303f7
// ANDROID64-NEXT: 00000000000304c9 0000000000000403 R_AARCH64_RELATIVE 303fa
// ANDROID64-NEXT: 0000000000030478 0000000100000101 R_AARCH64_ABS64 0000000000000000 bar2 + 0
// ANDROID64-NEXT: 00000000000304d1 0000000100000101 R_AARCH64_ABS64 0000000000000000 bar2 + 0
// ANDROID64-NEXT: 00000000000304e9 0000000100000101 R_AARCH64_ABS64 0000000000000000 bar2 + 0
// ANDROID64-NEXT: 0000000000030428 0000000100000101 R_AARCH64_ABS64 0000000000000000 bar2 + 1
// ANDROID64-NEXT: 0000000000030468 0000000200000101 R_AARCH64_ABS64 0000000000000000 zed2 + 0
// ANDROID64-NEXT: 00000000000304d9 0000000100000101 R_AARCH64_ABS64 0000000000000000 bar2 + 1
// ANDROID64-NEXT: 00000000000304d9 0000000100000101 R_AARCH64_ABS64 0000000000000000 bar2 + 0
// ANDROID64-NEXT: 00000000000304f1 0000000100000101 R_AARCH64_ABS64 0000000000000000 bar2 + 0
// ANDROID64-NEXT: 0000000000030430 0000000100000101 R_AARCH64_ABS64 0000000000000000 bar2 + 1
// ANDROID64-NEXT: 0000000000030470 0000000200000101 R_AARCH64_ABS64 0000000000000000 zed2 + 0
// ANDROID64-NEXT: 00000000000304e1 0000000100000101 R_AARCH64_ABS64 0000000000000000 bar2 + 1
// ANDROID64-NEXT: 00000000000304e9 0000000100000101 R_AARCH64_ABS64 0000000000000000 bar2 + 1
// ANDROID64-EMPTY:

// RUN: ld.lld -pie --pack-dyn-relocs=relr %t.a64.o %t.a64.so -o %t4.a64
Expand Down Expand Up @@ -317,7 +317,7 @@
/// Any relative relocations with odd offset stay in SHT_RELA.
// RELR64: Relocation section '.rela.dyn' at offset {{.*}} contains 9 entries:
// RELR64-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
// RELR64-NEXT: 0000000000030569 0000000000000403 R_AARCH64_RELATIVE a
// RELR64-NEXT: 0000000000030569 0000000000000403 R_AARCH64_RELATIVE 3049a
// RELR64-NEXT: 00000000000304d0 0000000100000101 R_AARCH64_ABS64 0000000000000000 bar2 + 1
// RELR64-NEXT: 0000000000030518 0000000100000101 R_AARCH64_ABS64 0000000000000000 bar2 + 0
// RELR64-NEXT: 0000000000030571 0000000100000101 R_AARCH64_ABS64 0000000000000000 bar2 + 0
Expand Down Expand Up @@ -355,43 +355,43 @@
// RELR64-NEXT: 0000000000030560 0000000000000403 R_AARCH64_RELATIVE
// RELR64-EMPTY:
// RELR64-NEXT: Hex dump of section '.data':
// RELR64-NEXT: 0x00030490 00000000 00000000 01000000 00000000 .
// RELR64-NEXT: 0x00030490 90040300 00000000 91040300 00000000 .
// RELR64-NEXT: 0x000304a0 02000000 00000000 ffffffff ffffffff .
// RELR64-NEXT: 0x000304b0 00000080 00000000 06000000 00000000 .

.data
.balign 2
.dc.a __ehdr_start
.dc.a __ehdr_start + 1
.dc.a .data
.dc.a .data + 1
.dc.a __ehdr_start + 2
.dc.a __ehdr_start - 1
.dc.a __ehdr_start + 0x80000000
.dc.a __ehdr_start + 6
.dc.a __ehdr_start + 7
.dc.a __ehdr_start + 8
.dc.a .data + 8
.dc.a bar2 + 1

.dc.a __ehdr_start + 1
.dc.a .data + 1
.dc.a __ehdr_start + 2
.dc.a __ehdr_start + 3
.dc.a __ehdr_start + 4
.dc.a __ehdr_start + 5
.dc.a __ehdr_start + 6
.dc.a __ehdr_start + 7
.dc.a .data + 7
.dc.a zed2
.dc.a bar2

.dc.a __ehdr_start + 1
.dc.a .data + 1
.dc.a __ehdr_start + 2
.dc.a __ehdr_start + 3
.dc.a __ehdr_start + 4
.dc.a __ehdr_start + 5
.dc.a __ehdr_start + 6
.dc.a __ehdr_start + 7
.dc.a __ehdr_start + 8
.dc.a __ehdr_start + 9
.dc.a .data + 9
.byte 00
.dc.a __ehdr_start + 10
.dc.a .data + 10
.dc.a bar2
.dc.a bar2
.dc.a bar2 + 1
Expand Down

0 comments on commit 3989e22

Please sign in to comment.