[lld] Make hashtable entry size configurable (PR #113431)

via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 23 02:12:31 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lld

@llvm/pr-subscribers-lld-elf

Author: Dominik Steenken (dominik-steenken)

<details>
<summary>Changes</summary>

This PR makes the size of hash table entries in ELF binaries configurable, instead of hard-coding that size to 4 bytes. This is done to enable special case handling for SystemZ, which uses 8 byte hash table entries. The change is provided in 2 steps:

1. Commit ea25c42 provides for configuring the hash table entry size without introducing a functional change.
2. Commit 065ca31 uses the previous commit to change the hash table entry size on SystemZ and updates all relevant tests.

Expected addresses and address references in the assembly of tests are moved by the original hash table size, in addition to any further alignment padding necessary.

---

Patch is 24.45 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/113431.diff


12 Files Affected:

- (modified) lld/ELF/Arch/SystemZ.cpp (+1) 
- (modified) lld/ELF/SyntheticSections.cpp (+28-11) 
- (modified) lld/ELF/SyntheticSections.h (+1) 
- (modified) lld/ELF/Target.h (+3) 
- (modified) lld/test/ELF/basic-systemz.s (+17-17) 
- (modified) lld/test/ELF/systemz-gotent-relax-und-dso.s (+19-19) 
- (modified) lld/test/ELF/systemz-pie.s (+5-5) 
- (modified) lld/test/ELF/systemz-reloc-got.s (+11-11) 
- (modified) lld/test/ELF/systemz-reloc-gotrel.s (+5-5) 
- (modified) lld/test/ELF/systemz-tls-gd.s (+36-36) 
- (modified) lld/test/ELF/systemz-tls-ie.s (+24-24) 
- (modified) lld/test/ELF/systemz-tls-ld.s (+15-15) 


``````````diff
diff --git a/lld/ELF/Arch/SystemZ.cpp b/lld/ELF/Arch/SystemZ.cpp
index 106b530c31b28b..f24bf66d28ff84 100644
--- a/lld/ELF/Arch/SystemZ.cpp
+++ b/lld/ELF/Arch/SystemZ.cpp
@@ -67,6 +67,7 @@ SystemZ::SystemZ(Ctx &ctx) : TargetInfo(ctx) {
   pltHeaderSize = 32;
   pltEntrySize = 32;
   ipltEntrySize = 32;
+  hashEntrySize = 8; // On SystemZ, .hash entries are 64 bit in size.
 
   // This "trap instruction" is used to fill gaps between sections.
   // On SystemZ, the behavior of the GNU ld is to fill those gaps
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 7a344635a1cb53..411664e61a49fc 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -2523,8 +2523,9 @@ void GnuHashTableSection::addSymbols(SmallVectorImpl<SymbolTableEntry> &v) {
 }
 
 HashTableSection::HashTableSection(Ctx &ctx)
-    : SyntheticSection(ctx, SHF_ALLOC, SHT_HASH, 4, ".hash") {
-  this->entsize = 4;
+    : SyntheticSection(ctx, SHF_ALLOC, SHT_HASH, ctx.target->hashEntrySize,
+                       ".hash") {
+  this->entsize = ctx.target->hashEntrySize;
 }
 
 void HashTableSection::finalizeContents() {
@@ -2538,30 +2539,46 @@ void HashTableSection::finalizeContents() {
 
   // Create as many buckets as there are symbols.
   numEntries += symTab->getNumSymbols();
-  this->size = numEntries * 4;
+  this->size = numEntries * this->entsize;
 }
 
 void HashTableSection::writeTo(uint8_t *buf) {
   SymbolTableBaseSection *symTab = getPartition(ctx).dynSymTab.get();
   unsigned numSymbols = symTab->getNumSymbols();
+  size_t size = this->entsize;
 
-  uint32_t *p = reinterpret_cast<uint32_t *>(buf);
-  write32(ctx, p++, numSymbols); // nbucket
-  write32(ctx, p++, numSymbols); // nchain
+  uint8_t *p = buf;
+  this->writeHashTable(ctx, p, numSymbols); // nbucket
+  p += size;
+  this->writeHashTable(ctx, p, numSymbols); // nchain
+  p += size;
 
-  uint32_t *buckets = p;
-  uint32_t *chains = p + numSymbols;
+  uint8_t *buckets = p;
+  uint8_t *chains = p + numSymbols * size;
 
   for (const SymbolTableEntry &s : symTab->getSymbols()) {
     Symbol *sym = s.sym;
     StringRef name = sym->getName();
     unsigned i = sym->dynsymIndex;
-    uint32_t hash = hashSysV(name) % numSymbols;
-    chains[i] = buckets[hash];
-    write32(ctx, buckets + hash, i);
+    uint64_t hash = hashSysV(name) % numSymbols;
+    // chains[i] = buckets[hash]
+    memcpy(chains + i * size, buckets + hash * size, size);
+    // buckets[hash] = i
+    this->writeHashTable(ctx, buckets + hash * size, i);
   }
 }
 
+inline void HashTableSection::writeHashTable(Ctx &ctx, uint8_t *buf,
+                                             uint64_t entry) const {
+  // All but SystemZ use 32-bit .hash entries.
+  if (this->entsize == 4)
+    write32(ctx, buf, entry);
+  else if (this->entsize == 8)
+    write64(ctx, buf, entry);
+  else
+    fatal("unsupported .hash entry size: " + Twine(this->entsize));
+}
+
 PltSection::PltSection(Ctx &ctx)
     : SyntheticSection(ctx, SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS, 16,
                        ".plt"),
diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h
index 3573767671feb1..844e5a41c4b551 100644
--- a/lld/ELF/SyntheticSections.h
+++ b/lld/ELF/SyntheticSections.h
@@ -721,6 +721,7 @@ class HashTableSection final : public SyntheticSection {
 
 private:
   size_t size = 0;
+  void writeHashTable(Ctx &ctx, uint8_t *buf, uint64_t entry) const;
 };
 
 // Used for PLT entries. It usually has a PLT header for lazy binding. Each PLT
diff --git a/lld/ELF/Target.h b/lld/ELF/Target.h
index 27986b0a127e8e..e8c36834deb22f 100644
--- a/lld/ELF/Target.h
+++ b/lld/ELF/Target.h
@@ -146,6 +146,9 @@ class TargetInfo {
   // On PPC ELF V2 abi, the first entry in the .got is the .TOC.
   unsigned gotHeaderEntriesNum = 0;
 
+  // All but SystemZ use 32-bit .hash entries.
+  unsigned hashEntrySize = 4;
+
   // On PPC ELF V2 abi, the dynamic section needs DT_PPC64_OPT (DT_LOPROC + 3)
   // to be set to 0x2 if there can be multiple TOC's. Although we do not emit
   // multiple TOC's, there can be a mix of TOC and NOTOC addressing which
diff --git a/lld/test/ELF/basic-systemz.s b/lld/test/ELF/basic-systemz.s
index f7bb0e8cbd020d..1a530322b6cb17 100644
--- a/lld/test/ELF/basic-systemz.s
+++ b/lld/test/ELF/basic-systemz.s
@@ -20,7 +20,7 @@
 # CHECK-NEXT:  Version:                           0x1
 # CHECK-NEXT:  Entry point address:               0x0
 # CHECK-NEXT:  Start of program headers:          64 (bytes into file)
-# CHECK-NEXT:  Start of section headers:          768 (bytes into file)
+# CHECK-NEXT:  Start of section headers:          784 (bytes into file)
 # CHECK-NEXT:  Flags:                             0x0
 # CHECK-NEXT:  Size of this header:               64 (bytes)
 # CHECK-NEXT:  Size of program headers:           56 (bytes)
@@ -33,31 +33,31 @@
 # CHECK-NEXT:  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
 # CHECK-NEXT:  [ 0]                   NULL            0000000000000000 000000 000000 00      0   0  0
 # CHECK-NEXT:  [ 1] .dynsym           DYNSYM          00000000000001c8 0001c8 000018 18   A  3   1  8
-# CHECK-NEXT:  [ 2] .hash             HASH            00000000000001e0 0001e0 000010 04   A  1   0  4
-# CHECK-NEXT:  [ 3] .dynstr           STRTAB          00000000000001f0 0001f0 000001 00   A  0   0  1
-# CHECK-NEXT:  [ 4] .text             PROGBITS        00000000000011f4 0001f4 000006 00  AX  0   0  4
-# CHECK-NEXT:  [ 5] .dynamic          DYNAMIC         0000000000002200 000200 000060 10  WA  3   0  8
-# CHECK-NEXT:  [ 6] .relro_padding    NOBITS          0000000000002260 000260 000da0 00  WA  0   0  1
-# CHECK-NEXT:  [ 7] .comment          PROGBITS        0000000000000000 000260 000008 01  MS  0   0  1
-# CHECK-NEXT:  [ 8] .symtab           SYMTAB          0000000000000000 000268 000030 18     10   2  8
-# CHECK-NEXT:  [ 9] .shstrtab         STRTAB          0000000000000000 000298 000058 00      0   0  1
-# CHECK-NEXT:  [10] .strtab           STRTAB          0000000000000000 0002f0 00000a 00      0   0  1
+# CHECK-NEXT:  [ 2] .hash             HASH            00000000000001e0 0001e0 000020 08   A  1   0  8
+# CHECK-NEXT:  [ 3] .dynstr           STRTAB          0000000000000200 000200 000001 00   A  0   0  1
+# CHECK-NEXT:  [ 4] .text             PROGBITS        0000000000001204 000204 000006 00  AX  0   0  4
+# CHECK-NEXT:  [ 5] .dynamic          DYNAMIC         0000000000002210 000210 000060 10  WA  3   0  8
+# CHECK-NEXT:  [ 6] .relro_padding    NOBITS          0000000000002270 000270 000d90 00  WA  0   0  1
+# CHECK-NEXT:  [ 7] .comment          PROGBITS        0000000000000000 000270 000008 01  MS  0   0  1
+# CHECK-NEXT:  [ 8] .symtab           SYMTAB          0000000000000000 000278 000030 18     10   2  8
+# CHECK-NEXT:  [ 9] .shstrtab         STRTAB          0000000000000000 0002a8 000058 00      0   0  1
+# CHECK-NEXT:  [10] .strtab           STRTAB          0000000000000000 000300 00000a 00      0   0  1
 
 # CHECK:       Program Headers:
 # CHECK-NEXT:  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
 # CHECK-NEXT:  PHDR           0x000040 0x0000000000000040 0x0000000000000040 0x000188 0x000188 R   0x8
-# CHECK-NEXT:  LOAD           0x000000 0x0000000000000000 0x0000000000000000 0x0001f1 0x0001f1 R   0x1000
-# CHECK-NEXT:  LOAD           0x0001f4 0x00000000000011f4 0x00000000000011f4 0x000006 0x000006 R E 0x1000
-# CHECK-NEXT:  LOAD           0x000200 0x0000000000002200 0x0000000000002200 0x000060 0x000e00 RW  0x1000
-# CHECK-NEXT:  DYNAMIC        0x000200 0x0000000000002200 0x0000000000002200 0x000060 0x000060 RW  0x8
-# CHECK-NEXT:  GNU_RELRO      0x000200 0x0000000000002200 0x0000000000002200 0x000060 0x000e00 R   0x1
+# CHECK-NEXT:  LOAD           0x000000 0x0000000000000000 0x0000000000000000 0x000201 0x000201 R   0x1000
+# CHECK-NEXT:  LOAD           0x000204 0x0000000000001204 0x0000000000001204 0x000006 0x000006 R E 0x1000
+# CHECK-NEXT:  LOAD           0x000210 0x0000000000002210 0x0000000000002210 0x000060 0x000df0 RW  0x1000
+# CHECK-NEXT:  DYNAMIC        0x000210 0x0000000000002210 0x0000000000002210 0x000060 0x000060 RW  0x8
+# CHECK-NEXT:  GNU_RELRO      0x000210 0x0000000000002210 0x0000000000002210 0x000060 0x000df0 R   0x1
 # CHECK-NEXT:  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW  0x0
 
-# CHECK:       Dynamic section at offset 0x200 contains 6 entries:
+# CHECK:       Dynamic section at offset 0x210 contains 6 entries:
 # CHECK-NEXT:  Tag                Type     Name/Value
 # CHECK-NEXT:  0x0000000000000006 (SYMTAB) 0x1c8
 # CHECK-NEXT:  0x000000000000000b (SYMENT) 24 (bytes)
-# CHECK-NEXT:  0x0000000000000005 (STRTAB) 0x1f0
+# CHECK-NEXT:  0x0000000000000005 (STRTAB) 0x200
 # CHECK-NEXT:  0x000000000000000a (STRSZ)  1 (bytes)
 # CHECK-NEXT:  0x0000000000000004 (HASH)   0x1e0
 # CHECK-NEXT:  0x0000000000000000 (NULL)   0x0
diff --git a/lld/test/ELF/systemz-gotent-relax-und-dso.s b/lld/test/ELF/systemz-gotent-relax-und-dso.s
index 5a1bd7f949f897..97b33dbad48926 100644
--- a/lld/test/ELF/systemz-gotent-relax-und-dso.s
+++ b/lld/test/ELF/systemz-gotent-relax-und-dso.s
@@ -7,9 +7,9 @@
 # RUN: llvm-objdump --no-print-imm-hex -d %t | FileCheck --check-prefix=DISASM %s
 
 # RELOC-LABEL: Relocation section '.rela.dyn' at offset {{.*}} contains 3 entries:
-# RELOC: 00000000000023f8 000000010000000a R_390_GLOB_DAT 00000000000012d8 foo + 0
-# RELOC: 0000000000002400 000000030000000a R_390_GLOB_DAT 0000000000000000 und + 0
-# RELOC: 0000000000002408 000000040000000a R_390_GLOB_DAT 0000000000000000 dsofoo + 0
+# RELOC: 0000000000002428 000000010000000a R_390_GLOB_DAT 0000000000001308 foo + 0
+# RELOC: 0000000000002430 000000030000000a R_390_GLOB_DAT 0000000000000000 und + 0
+# RELOC: 0000000000002438 000000040000000a R_390_GLOB_DAT 0000000000000000 dsofoo + 0
 
 # DISASM:      Disassembly of section .text:
 # DISASM-EMPTY:
@@ -18,22 +18,22 @@
 # DISASM:      <hid>:
 # DISASM-NEXT:     nop     0
 # DISASM:      <_start>:
-# DISASM-NEXT:    lgrl    %r1, 0x2400
-# DISASM-NEXT:    lgrl    %r1, 0x2400
-# DISASM-NEXT:    lgrl    %r1, 0x2408
-# DISASM-NEXT:    lgrl    %r1, 0x2408
-# DISASM-NEXT:    larl    %r1, 0x12dc
-# DISASM-NEXT:    larl    %r1, 0x12dc
-# DISASM-NEXT:    lgrl    %r1, 0x23f8
-# DISASM-NEXT:    lgrl    %r1, 0x23f8
-# DISASM-NEXT:    lgrl    %r1, 0x2400
-# DISASM-NEXT:    lgrl    %r1, 0x2400
-# DISASM-NEXT:    lgrl    %r1, 0x2408
-# DISASM-NEXT:    lgrl    %r1, 0x2408
-# DISASM-NEXT:    larl    %r1, 0x12dc
-# DISASM-NEXT:    larl    %r1, 0x12dc
-# DISASM-NEXT:    lgrl    %r1, 0x23f8
-# DISASM-NEXT:    lgrl    %r1, 0x23f8
+# DISASM-NEXT:    lgrl    %r1, 0x2430
+# DISASM-NEXT:    lgrl    %r1, 0x2430
+# DISASM-NEXT:    lgrl    %r1, 0x2438
+# DISASM-NEXT:    lgrl    %r1, 0x2438
+# DISASM-NEXT:    larl    %r1, 0x130c
+# DISASM-NEXT:    larl    %r1, 0x130c
+# DISASM-NEXT:    lgrl    %r1, 0x2428
+# DISASM-NEXT:    lgrl    %r1, 0x2428
+# DISASM-NEXT:    lgrl    %r1, 0x2430
+# DISASM-NEXT:    lgrl    %r1, 0x2430
+# DISASM-NEXT:    lgrl    %r1, 0x2438
+# DISASM-NEXT:    lgrl    %r1, 0x2438
+# DISASM-NEXT:    larl    %r1, 0x130c
+# DISASM-NEXT:    larl    %r1, 0x130c
+# DISASM-NEXT:    lgrl    %r1, 0x2428
+# DISASM-NEXT:    lgrl    %r1, 0x2428
 
 .text
 .globl foo
diff --git a/lld/test/ELF/systemz-pie.s b/lld/test/ELF/systemz-pie.s
index bb971a82fb8ced..57ae10bff57393 100644
--- a/lld/test/ELF/systemz-pie.s
+++ b/lld/test/ELF/systemz-pie.s
@@ -19,13 +19,13 @@
 # CHECK: Program Headers:
 # CHECK-NEXT:  Type           Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
 # CHECK-NEXT:  PHDR           0x000040 0x0000000000000040 0x0000000000000040 0x000188 0x000188 R   0x8
-# CHECK-NEXT:  LOAD           0x000000 0x0000000000000000 0x0000000000000000 0x00020d 0x00020d R   0x1000
-# CHECK-NEXT:  LOAD           0x000210 0x0000000000002210 0x0000000000002210 0x000090 0x000df0 RW  0x1000
-# CHECK-NEXT:  DYNAMIC        0x000210 0x0000000000002210 0x0000000000002210 0x000090 0x000090 RW  0x8
-# CHECK-NEXT:  GNU_RELRO      0x000210 0x0000000000002210 0x0000000000002210 0x000090 0x000df0 R   0x1
+# CHECK-NEXT:  LOAD           0x000000 0x0000000000000000 0x0000000000000000 0x000221 0x000221 R   0x1000
+# CHECK-NEXT:  LOAD           0x000228 0x0000000000002228 0x0000000000002228 0x000090 0x000dd8 RW  0x1000
+# CHECK-NEXT:  DYNAMIC        0x000228 0x0000000000002228 0x0000000000002228 0x000090 0x000090 RW  0x8
+# CHECK-NEXT:  GNU_RELRO      0x000228 0x0000000000002228 0x0000000000002228 0x000090 0x000dd8 R   0x1
 # CHECK-NEXT:  GNU_STACK      0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW  0x0
 
-# CHECK: Dynamic section at offset 0x210 contains 9 entries:
+# CHECK: Dynamic section at offset 0x228 contains 9 entries:
 # CHECK-NEXT:   Tag                Type       Name/Value
 # CHECK-NEXT:   0x000000006ffffffb (FLAGS_1)  PIE
 
diff --git a/lld/test/ELF/systemz-reloc-got.s b/lld/test/ELF/systemz-reloc-got.s
index 4b9ac16481f4cb..5e5f442791b992 100644
--- a/lld/test/ELF/systemz-reloc-got.s
+++ b/lld/test/ELF/systemz-reloc-got.s
@@ -8,20 +8,20 @@
 # RUN: llvm-objdump -d --no-show-raw-insn %t.so | FileCheck %s --check-prefix=DISASM
 
 # CHECK: Section Headers:
-# CHECK: .got PROGBITS 0000000000002458
-# CHECK: .got.plt PROGBITS 0000000000002480
+# CHECK: .got PROGBITS 0000000000002478
+# CHECK: .got.plt PROGBITS 00000000000024a0
 
 ## Note: _GLOBAL_OFFSET_TABLE is at .got
-## GOT (foo) is at .got + 24 == 0x2470
-## GOT (bar) is at .got + 32 == 0x2478
-## GOTPLT (foo) is at .got.plt + 0 == .got + 40 == 0x2480
-## GOTPLT (bar) is at .got.plt + 8 == .got + 48 == 0x2488
+## GOT (foo) is at .got + 24 == 0x2490
+## GOT (bar) is at .got + 32 == 0x2498
+## GOTPLT (foo) is at .got.plt + 0 == .got + 40 == 0x24a0
+## GOTPLT (bar) is at .got.plt + 8 == .got + 48 == 0x24a8
 
-# DISASM:      larl %r12, 0x2458
-# DISASM-NEXT: larl %r1, 0x2470
-# DISASM-NEXT: larl %r1, 0x2478
-# DISASM-NEXT: larl %r1, 0x2480
-# DISASM-NEXT: larl %r1, 0x2488
+# DISASM:      larl %r12, 0x2478
+# DISASM-NEXT: larl %r1, 0x2490
+# DISASM-NEXT: larl %r1, 0x2498
+# DISASM-NEXT: larl %r1, 0x24a0
+# DISASM-NEXT: larl %r1, 0x24a8
 
 # DISASM-NEXT: l %r1, 24(%r12)
 # DISASM-NEXT: l %r1, 32(%r12)
diff --git a/lld/test/ELF/systemz-reloc-gotrel.s b/lld/test/ELF/systemz-reloc-gotrel.s
index 46669ecfa7fd01..1e24ea196e6cc8 100644
--- a/lld/test/ELF/systemz-reloc-gotrel.s
+++ b/lld/test/ELF/systemz-reloc-gotrel.s
@@ -5,15 +5,15 @@
 # RUN: llvm-readelf -S -s -x .data %t.so | FileCheck %s
 
 # CHECK: Section Headers:
-# CHECK: .plt PROGBITS 0000000000001290
-# CHECK: .got PROGBITS 0000000000002390
+# CHECK: .plt PROGBITS 00000000000012b0
+# CHECK: .got PROGBITS 00000000000023b0
 
 # CHECK: Symbol table '.symtab'
-# CHECK: 0000000000001288 {{.*}}  bar
+# CHECK: 00000000000012a8 {{.*}}  bar
 
 ## Note: foo is the first (and only) PLT entry, which resides at .plt + 32
-## PLTOFF (foo) is (.plt + 32) - .got == 0x12b0 - 0x2390 == 0xffffef20
-## GOTOFF (bar) is bar - .got == 0x1288 - 0x2390 == 0xffffeef8
+## PLTOFF (foo) is (.plt + 32) - .got == 0x12d0 - 0x23b0 == 0xffffef20
+## GOTOFF (bar) is bar - .got == 0x12a8 - 0x23b0 == 0xffffeef8
 # CHECK: Hex dump of section '.data':
 # CHECK-NEXT: eef8ef20 ffffeef8 ffffef20 ffffffff
 # CHECK-NEXT: ffffeef8 ffffffff ffffef20
diff --git a/lld/test/ELF/systemz-tls-gd.s b/lld/test/ELF/systemz-tls-gd.s
index 3976f55a6ae39e..fe9f2ca1bb3242 100644
--- a/lld/test/ELF/systemz-tls-gd.s
+++ b/lld/test/ELF/systemz-tls-gd.s
@@ -19,37 +19,37 @@
 # RUN: llvm-objdump --section .data.rel.ro --full-contents %t.ie | FileCheck --check-prefix=IE-DATA %s
 
 # GD-REL: Relocation section '.rela.dyn' at offset {{.*}} contains 6 entries:
-# GD-REL:      0000000000002570 0000000200000036 R_390_TLS_DTPMOD 0000000000000008 a + 0
-# GD-REL-NEXT: 0000000000002578 0000000200000037 R_390_TLS_DTPOFF 0000000000000008 a + 0
-# GD-REL-NEXT: 0000000000002580 0000000300000036 R_390_TLS_DTPMOD 000000000000000c b + 0
-# GD-REL-NEXT: 0000000000002588 0000000300000037 R_390_TLS_DTPOFF 000000000000000c b + 0
-# GD-REL-NEXT: 0000000000002590 0000000400000036 R_390_TLS_DTPMOD 0000000000000010 c + 0
-# GD-REL-NEXT: 0000000000002598 0000000400000037 R_390_TLS_DTPOFF 0000000000000010 c + 0
-
-## _GLOBAL_OFFSET_TABLE is at 0x2558
-# GD:      larl    %r12, 0x2558
-
-## GOT offset of the TLS module ID / offset pair for a is at 0x2460
-# GD-NEXT: lgrl    %r2, 0x2460
-# GD-NEXT: brasl   %r14, 0x1440
+# GD-REL:      00000000000025a0 0000000200000036 R_390_TLS_DTPMOD 0000000000000008 a + 0
+# GD-REL-NEXT: 00000000000025a8 0000000200000037 R_390_TLS_DTPOFF 0000000000000008 a + 0
+# GD-REL-NEXT: 00000000000025b0 0000000300000036 R_390_TLS_DTPMOD 000000000000000c b + 0
+# GD-REL-NEXT: 00000000000025b8 0000000300000037 R_390_TLS_DTPOFF 000000000000000c b + 0
+# GD-REL-NEXT: 00000000000025c0 0000000400000036 R_390_TLS_DTPMOD 0000000000000010 c + 0
+# GD-REL-NEXT: 00000000000025c8 0000000400000037 R_390_TLS_DTPOFF 0000000000000010 c + 0
+
+## _GLOBAL_OFFSET_TABLE is at 0x2588
+# GD:      larl    %r12, 0x2588
+
+## GOT offset of the TLS module ID / offset pair for a is at 0x2490
+# GD-NEXT: lgrl    %r2, 0x2490
+# GD-NEXT: brasl   %r14, 0x1470
 # GD-NEXT: lgf     %r2, 0(%r2,%r7)
 
 ## GOT offset of the TLS module ID / offset pair for b is at 0x2468
-# GD-NEXT: lgrl    %r2, 0x2468
-# GD-NEXT: brasl   %r14, 0x1440
+# GD-NEXT: lgrl    %r2, 0x2498
+# GD-NEXT: brasl   %r14, 0x1470
 # GD-NEXT: lgf     %r2, 0(%r2,%r7)
 
 ## GOT offset of the TLS module ID / offset pair for c is at 0x2470
-# GD-NEXT: lgrl    %r2, 0x2470
-# GD-NEXT: brasl   %r14, 0x1440
+# GD-NEXT: lgrl    %r2, 0x24a0
+# GD-NEXT: brasl   %r14, 0x1470
 # GD-NEXT: lgf     %r2, 0(%r2,%r7)
 
 ## Constant pool holding GOT offsets of TLS module ID / offset pairs:
-# a: 0x2570 / 0x18
-# b: 0x2580 / 0x28
-# c: 0x2590 / 0x38
-# GD-DATA:      2460 00000000 00000018 00000000 00000028
-# GD-DATA-NEXT: 2470 00000000 00000038
+# a: 0x25a0 / 0x18
+# b: 0x25b0 / 0x28
+# c: 0x25c0 / 0x38
+# GD-DATA:      2490 00000000 00000018 00000000 00000028
+# GD-DATA-NEXT: 24a0 00000000 00000038
 
 # NOREL: no relocations
 
@@ -80,33 +80,33 @@
 
 
 # IE-REL: Relocation section '.rela.dyn' at offset {{.*}} contains 2 entries:
-# IE-REL:      0000000001002430 0000000200000038 R_390_TLS_TPOFF 0000000000000000 b + 0
-# IE-REL-NEXT: 0000000001002438 0000000300000038 R_390_TLS_TPOFF 0000000000000000 c + 0
+# IE-REL:      0000000001002460 0000000200000038 R_390_TLS_TPOFF 0000000000000000 b + 0
+# IE-REL-NEXT: 0000000001002468 0000000300000038 R_390_TLS_TPOFF 0000000000000000 c + 0
 
-## _GLOBAL_OFFSET_TABLE is at 0x1002418
-# IE:      larl    %r12, 0x1002418
+## _GLOBAL_OFFSET_TABLE is at 0x1002448
+# IE:      larl    %r12, 0x1002448
 
-## TP offset of a is at 0x1002340
-# IE-NEXT: lgrl    %r2, 0x1002340
+## TP offset of a is at 0x1002370
+# IE-NEXT: lgrl    %r2, 0x1002370
 # IE-NEXT: brcl    0,
 # IE-NEXT: lgf     %r2, 0(%r2,%r7)
 
-## GOT offset of the TP offset for b is at 0x1002348
-# IE-NEXT: lgrl    %r2, 0x1002348
+## GOT offset of the TP offset for b is at 0x1002378
+# IE-NEXT: lgrl    %r2, 0x1002378
 # IE-NEXT: lg      %r2, 0(%r2,%r12)
 # IE-NEXT: lgf     %r2, 0(%r2,%r7)
 
-## GOT offset of the TP offset for c is at 0x1002350
-# IE-NEXT: lgrl    %r2, 0x1002350
+## GOT offset of the TP offset for c is at 0x1002380
+# IE-NEXT: lgrl    %r2, 0x1002380
 # IE-NEXT: lg      %r2, 0(%r2,%r12)
 # IE-NEXT: lgf     %r2, 0(%r2,%r7)
 
 ## TP offsets (a) / GOT offset of TP offsets (b, c)
 # a: -4
-# b: 0x1002430 / 0x18
-# c: 0x1002438 / 0x20
-# IE-DATA:      1002340 ffffffff fffffffc 00000000 00000018
-# IE-DATA-NEXT: 1002350 00000000 00000020
+# b: 0x1002460 / 0x18
+# c: 0x1002468 / 0x20
+# IE-DATA:      1002370 ffffffff fffffffc 00000000 00000018
+# IE-DATA-NEXT: 1002380 00000000 00000020
 
 
 ear     %r7,%a0
diff --git a/lld/test/ELF/systemz-tls-ie.s b/lld/test/ELF/systemz-tls-ie.s
index 85e2f24cb61f62..42114707f2bed5 100644
--- a/lld/test/ELF/systemz-tls-ie.s
+++ b/lld/test/ELF/systemz-tls-ie.s
@@ -21,25 +21,25 @@
 # RUN: llvm-objdump --section .got --full-contents %t.pie | FileCheck --check-prefix=PIE-GOT %s
 
 # IE-REL: Relocation section '.rela.dyn' at offset {{.*}} contains 4 entries:
-# IE-REL: 0000000000003478 000000000000000c R_390_RELATIVE 2460
-# IE-REL: 0000000000002460 0000000100000038 R_390_TLS_TPOFF 0000000000000008 a + 0
-# IE-RE...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/113431


More information about the llvm-commits mailing list