[lld] [RISCV][ELF] Set maximum page size to 65536 (PR #100995)

Pengcheng Wang via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 29 02:23:34 PDT 2024


https://github.com/wangpc-pp created https://github.com/llvm/llvm-project/pull/100995

This is an ahead work.

We have a 64K page support PoC in https://lwn.net/Articles/952722.


>From 2a8683fe95f1d67cd02ea66bf7948efb1541dced Mon Sep 17 00:00:00 2001
From: Wang Pengcheng <wangpengcheng.pp at bytedance.com>
Date: Mon, 29 Jul 2024 17:21:29 +0800
Subject: [PATCH] [RISCV][ELF] Set maximum page size to 65536

This is an ahead work.

We have a 64K page support PoC in https://lwn.net/Articles/952722.
---
 lld/ELF/Arch/RISCV.cpp                    |  1 +
 lld/test/ELF/riscv-branch.s               | 16 +++----
 lld/test/ELF/riscv-gp.s                   |  8 ++--
 lld/test/ELF/riscv-ifunc-nonpreemptible.s | 24 +++++-----
 lld/test/ELF/riscv-jal.s                  | 16 +++----
 lld/test/ELF/riscv-plt.s                  | 30 ++++++------
 lld/test/ELF/riscv-reloc-copy.s           |  8 ++--
 lld/test/ELF/riscv-reloc-got.s            | 26 +++++------
 lld/test/ELF/riscv-tls-gd.s               | 42 ++++++++---------
 lld/test/ELF/riscv-tls-ie.s               | 22 ++++-----
 lld/test/ELF/riscv-tls-ld.s               | 28 ++++++------
 lld/test/ELF/riscv-tlsdesc-relax.s        | 20 ++++----
 lld/test/ELF/riscv-tlsdesc.s              | 56 +++++++++++------------
 lld/test/ELF/riscv-undefined-weak.s       |  6 +--
 lld/test/ELF/riscv32-reloc-32-pic.s       |  6 +--
 lld/test/ELF/riscv64-reloc-64-pic.s       |  6 +--
 lld/test/ELF/riscv64-reloc-got32-pcrel.s  |  4 +-
 17 files changed, 160 insertions(+), 159 deletions(-)

diff --git a/lld/ELF/Arch/RISCV.cpp b/lld/ELF/Arch/RISCV.cpp
index 56759c28dcf41..61217231c52fb 100644
--- a/lld/ELF/Arch/RISCV.cpp
+++ b/lld/ELF/Arch/RISCV.cpp
@@ -135,6 +135,7 @@ RISCV::RISCV() {
   pltHeaderSize = 32;
   pltEntrySize = 16;
   ipltEntrySize = 16;
+  defaultMaxPageSize = 65536;
 }
 
 static uint32_t getEFlags(InputFile *f) {
diff --git a/lld/test/ELF/riscv-branch.s b/lld/test/ELF/riscv-branch.s
index 1a2b446b5a43b..0b4c5cc35acf7 100644
--- a/lld/test/ELF/riscv-branch.s
+++ b/lld/test/ELF/riscv-branch.s
@@ -7,19 +7,19 @@
 # RUN: ld.lld %t.rv64.o --defsym foo=_start+4 --defsym bar=_start -o %t.rv64
 # RUN: llvm-objdump -d %t.rv32 | FileCheck %s --check-prefix=CHECK-32
 # RUN: llvm-objdump -d %t.rv64 | FileCheck %s --check-prefix=CHECK-64
-# CHECK-32: 00000263     beqz    zero, 0x110b8
-# CHECK-32: fe001ee3     bnez    zero, 0x110b4
-# CHECK-64: 00000263     beqz    zero, 0x11124
-# CHECK-64: fe001ee3     bnez    zero, 0x11120
+# CHECK-32: 00000263     beqz    zero, 0x200b8
+# CHECK-32: fe001ee3     bnez    zero, 0x200b4
+# CHECK-64: 00000263     beqz    zero, 0x20124
+# CHECK-64: fe001ee3     bnez    zero, 0x20120
 #
 # RUN: ld.lld %t.rv32.o --defsym foo=_start+0xffe --defsym bar=_start+4-0x1000 -o %t.rv32.limits
 # RUN: ld.lld %t.rv64.o --defsym foo=_start+0xffe --defsym bar=_start+4-0x1000 -o %t.rv64.limits
 # RUN: llvm-objdump -d %t.rv32.limits | FileCheck --check-prefix=LIMITS-32 %s
 # RUN: llvm-objdump -d %t.rv64.limits | FileCheck --check-prefix=LIMITS-64 %s
-# LIMITS-32:      7e000fe3     beqz    zero, 0x120b2
-# LIMITS-32-NEXT: 80001063     bnez    zero, 0x100b8
-# LIMITS-64:      7e000fe3     beqz    zero, 0x1211e
-# LIMITS-64-NEXT: 80001063     bnez    zero, 0x10124
+# LIMITS-32:      7e000fe3     beqz    zero, 0x210b2
+# LIMITS-32-NEXT: 80001063     bnez    zero, 0x1f0b8
+# LIMITS-64:      7e000fe3     beqz    zero, 0x2111e
+# LIMITS-64-NEXT: 80001063     bnez    zero, 0x1f124
 
 # RUN: not ld.lld %t.rv32.o --defsym foo=_start+0x1000 --defsym bar=_start+4-0x1002 -o /dev/null 2>&1 | FileCheck --check-prefix=ERROR-RANGE %s
 # RUN: not ld.lld %t.rv64.o --defsym foo=_start+0x1000 --defsym bar=_start+4-0x1002 -o /dev/null 2>&1 | FileCheck --check-prefix=ERROR-RANGE %s
diff --git a/lld/test/ELF/riscv-gp.s b/lld/test/ELF/riscv-gp.s
index e82e36ee9a7ae..ecd7bd59ec3ff 100644
--- a/lld/test/ELF/riscv-gp.s
+++ b/lld/test/ELF/riscv-gp.s
@@ -10,11 +10,11 @@
 # RUN: not ld.lld -shared %t.64.o -o /dev/null 2>&1 | FileCheck --check-prefix=ERR %s
 
 ## __global_pointer$ = .sdata+0x800 = 0x39c0
-# SEC32: [ [[#SDATA:]]] .sdata PROGBITS {{0*}}000031c0
-# SEC32: {{0*}}000039c0 0 NOTYPE GLOBAL DEFAULT [[#SDATA]] __global_pointer$
+# SEC32: [ [[#SDATA:]]] .sdata PROGBITS {{0*}}000301c0
+# SEC32: {{0*}}000309c0 0 NOTYPE GLOBAL DEFAULT [[#SDATA]] __global_pointer$
 
-# SEC64: [ [[#SDATA:]]] .sdata PROGBITS {{0*}}000032e0
-# SEC64: {{0*}}00003ae0 0 NOTYPE GLOBAL DEFAULT [[#SDATA]] __global_pointer$
+# SEC64: [ [[#SDATA:]]] .sdata PROGBITS {{0*}}000302e0
+# SEC64: {{0*}}00030ae0 0 NOTYPE GLOBAL DEFAULT [[#SDATA]] __global_pointer$
 
 # ERR: error: relocation R_RISCV_PCREL_HI20 cannot be used against symbol '__global_pointer$'; recompile with -fPIC
 
diff --git a/lld/test/ELF/riscv-ifunc-nonpreemptible.s b/lld/test/ELF/riscv-ifunc-nonpreemptible.s
index eda5548eef8b9..e785230eb9c2d 100644
--- a/lld/test/ELF/riscv-ifunc-nonpreemptible.s
+++ b/lld/test/ELF/riscv-ifunc-nonpreemptible.s
@@ -16,43 +16,43 @@
 # RUN: llvm-objdump -d --no-show-raw-insn %t.64 | FileCheck --check-prefix=DIS64 %s
 
 # RELOC32:      .rela.dyn {
-# RELOC32-NEXT:   0x3200 R_RISCV_IRELATIVE - 0x117C
+# RELOC32-NEXT:   0x30200 R_RISCV_IRELATIVE - 0x1017C
 # RELOC32-NEXT: }
 # RELOC32-LABEL:    Hex dump of section '.got.plt':
-# NO-APPLY-RELOC32: 0x00003200 00000000
-# APPLY-RELOC32:    0x00003200 7c110000
+# NO-APPLY-RELOC32: 0x00030200 00000000
+# APPLY-RELOC32:    0x00030200 7c010100
 # RELOC32-EMPTY:
 
-# SYM32: 0001190 0 FUNC GLOBAL DEFAULT {{.*}} func
+# SYM32: 00010190 0 FUNC GLOBAL DEFAULT {{.*}} func
 
 # DIS32:      <_start>:
-# DIS32-NEXT: 1180: auipc a0, 0x0
+# DIS32-NEXT: 10180: auipc a0, 0x0
 # DIS32-NEXT:       addi a0, a0, 0x10
 # DIS32:      Disassembly of section .iplt:
 # DIS32:      <func>:
 ## 32-bit: &.got.plt[func]-. = 0x3200-0x1190 = 4096*2+0x70
-# DIS32-NEXT: 1190: auipc t3, 0x2
+# DIS32-NEXT: 10190: auipc t3, 0x2
 # DIS32-NEXT:       lw t3, 0x70(t3)
 # DIS32-NEXT:       jalr t1, t3
 # DIS32-NEXT:       nop
 
 # RELOC64:      .rela.dyn {
-# RELOC64-NEXT:   0x3340 R_RISCV_IRELATIVE - 0x1260
+# RELOC64-NEXT:   0x30340 R_RISCV_IRELATIVE - 0x10260
 # RELOC64-NEXT: }
 # RELOC64-LABEL:    Hex dump of section '.got.plt':
-# NO-APPLY-RELOC64: 0x00003340 00000000 00000000
-# APPLY-RELOC64:    0x00003340 60120000 00000000
+# NO-APPLY-RELOC64: 0x00030340 00000000 00000000
+# APPLY-RELOC64:    0x00030340 60020100 00000000
 # RELOC64-EMPTY:
 
-# SYM64: 000000000001270 0 FUNC GLOBAL DEFAULT {{.*}} func
+# SYM64: 0000000000010270 0 FUNC GLOBAL DEFAULT {{.*}} func
 
 # DIS64:      <_start>:
-# DIS64-NEXT: 1264: auipc a0, 0x0
+# DIS64-NEXT: 10264: auipc a0, 0x0
 # DIS64-NEXT:       addi a0, a0, 0xc
 # DIS64:      Disassembly of section .iplt:
 # DIS64:      <func>:
 ## 64-bit: &.got.plt[func]-. = 0x3340-0x1270 = 4096*2+0xd0
-# DIS64-NEXT: 1270: auipc t3, 0x2
+# DIS64-NEXT: 10270: auipc t3, 0x2
 # DIS64-NEXT:       ld t3, 0xd0(t3)
 # DIS64-NEXT:       jalr t1, t3
 # DIS64-NEXT:       nop
diff --git a/lld/test/ELF/riscv-jal.s b/lld/test/ELF/riscv-jal.s
index 2129e44547066..d78fff7d06819 100644
--- a/lld/test/ELF/riscv-jal.s
+++ b/lld/test/ELF/riscv-jal.s
@@ -7,19 +7,19 @@
 # RUN: ld.lld %t.rv64.o --defsym foo=_start+4 --defsym bar=_start -o %t.rv64
 # RUN: llvm-objdump -d %t.rv32 | FileCheck %s --check-prefix=CHECK-32
 # RUN: llvm-objdump -d %t.rv64 | FileCheck %s --check-prefix=CHECK-64
-# CHECK-32: 0040006f    j   0x110b8
-# CHECK-32: ffdff0ef    jal 0x110b4
-# CHECK-64: 0040006f    j   0x11124
-# CHECK-64: ffdff0ef    jal 0x11120
+# CHECK-32: 0040006f    j   0x200b8
+# CHECK-32: ffdff0ef    jal 0x200b4
+# CHECK-64: 0040006f    j   0x20124
+# CHECK-64: ffdff0ef    jal 0x20120
 
 # RUN: ld.lld %t.rv32.o --defsym foo=_start+0xffffe --defsym bar=_start+4-0x100000 -o %t.rv32.limits
 # RUN: ld.lld %t.rv64.o --defsym foo=_start+0xffffe --defsym bar=_start+4-0x100000 -o %t.rv64.limits
 # RUN: llvm-objdump -d %t.rv32.limits | FileCheck --check-prefix=LIMITS-32 %s
 # RUN: llvm-objdump -d %t.rv64.limits | FileCheck --check-prefix=LIMITS-64 %s
-# LIMITS-32:      7ffff06f j   0x1110b2
-# LIMITS-32-NEXT: 800000ef jal 0xfff110b8
-# LIMITS-64:      7ffff06f j   0x11111e
-# LIMITS-64-NEXT: 800000ef jal 0xfffffffffff11124
+# LIMITS-32:      7ffff06f j   0x1200b2
+# LIMITS-32-NEXT: 800000ef jal 0xfff200b8
+# LIMITS-64:      7ffff06f j   0x12011e
+# LIMITS-64-NEXT: 800000ef jal 0xfffffffffff20124
 
 # RUN: not ld.lld %t.rv32.o --defsym foo=_start+0x100000 --defsym bar=_start+4-0x100002 -o /dev/null 2>&1 | FileCheck --check-prefix=ERROR-RANGE %s
 # RUN: not ld.lld %t.rv64.o --defsym foo=_start+0x100000 --defsym bar=_start+4-0x100002 -o /dev/null 2>&1 | FileCheck --check-prefix=ERROR-RANGE %s
diff --git a/lld/test/ELF/riscv-plt.s b/lld/test/ELF/riscv-plt.s
index 4b3649e3ba8df..98e9e8f30f41e 100644
--- a/lld/test/ELF/riscv-plt.s
+++ b/lld/test/ELF/riscv-plt.s
@@ -19,7 +19,7 @@
 # RUN: llvm-readelf -x .got.plt %t.64 | FileCheck --check-prefix=GOTPLT64 %s
 # RUN: llvm-objdump -d --no-show-raw-insn %t.64 | FileCheck --check-prefixes=DIS,DIS64 %s
 
-# SEC: .plt PROGBITS {{0*}}00011030
+# SEC: .plt PROGBITS {{0*}}00020030
 
 ## A canonical PLT has a non-zero st_value. bar and weak are called but their
 ## addresses are not taken, so a canonical PLT is not necessary.
@@ -29,36 +29,36 @@
 ## The .got.plt slots relocated by .rela.plt point to .plt
 ## This is required by glibc.
 # RELOC32:      .rela.plt {
-# RELOC32-NEXT:   0x13070 R_RISCV_JUMP_SLOT bar 0x0
-# RELOC32-NEXT:   0x13074 R_RISCV_JUMP_SLOT weak 0x0
+# RELOC32-NEXT:   0x40070 R_RISCV_JUMP_SLOT bar 0x0
+# RELOC32-NEXT:   0x40074 R_RISCV_JUMP_SLOT weak 0x0
 # RELOC32-NEXT: }
 # GOTPLT32:      section '.got.plt'
-# GOTPLT32-NEXT: 0x00013068 00000000 00000000 30100100 30100100
+# GOTPLT32-NEXT: 0x00040068 00000000 00000000 30000200 30000200
 
 # RELOC64:      .rela.plt {
-# RELOC64-NEXT:   0x130E0 R_RISCV_JUMP_SLOT bar 0x0
-# RELOC64-NEXT:   0x130E8 R_RISCV_JUMP_SLOT weak 0x0
+# RELOC64-NEXT:   0x400E0 R_RISCV_JUMP_SLOT bar 0x0
+# RELOC64-NEXT:   0x400E8 R_RISCV_JUMP_SLOT weak 0x0
 # RELOC64-NEXT: }
 # GOTPLT64:      section '.got.plt'
-# GOTPLT64-NEXT: 0x000130d0 00000000 00000000 00000000 00000000
-# GOTPLT64-NEXT: 0x000130e0 30100100 00000000 30100100 00000000
+# GOTPLT64-NEXT: 0x000400d0 00000000 00000000 00000000 00000000
+# GOTPLT64-NEXT: 0x000400e0 30000200 00000000 30000200 00000000
 
 # DIS:      <_start>:
 ## Direct call
 ## foo - . = 0x11020-0x11000 = 32
-# DIS-NEXT:   11000: auipc ra, 0x0
+# DIS-NEXT:   20000: auipc ra, 0x0
 # DIS-NEXT:          jalr 0x20(ra)
 ## bar at plt - . = 0x11050-0x11008 = 72
-# DIS-NEXT:   11008: auipc ra, 0x0
+# DIS-NEXT:   20008: auipc ra, 0x0
 # DIS-NEXT:          jalr 0x48(ra)
 ## bar at plt - . = 0x11050-0x11010 = 64
-# DIS-NEXT:   11010: auipc ra, 0x0
+# DIS-NEXT:   20010: auipc ra, 0x0
 # DIS-NEXT:          jalr 0x40(ra)
 ## weak at plt - . = 0x11060-0x11018 = 72
-# DIS-NEXT:   11018: auipc ra, 0x0
+# DIS-NEXT:   20018: auipc ra, 0x0
 # DIS-NEXT:          jalr 0x48(ra)
 # DIS:      <foo>:
-# DIS-NEXT:   11020:
+# DIS-NEXT:   20020:
 
 # DIS:      Disassembly of section .plt:
 # DIS:      <.plt>:
@@ -77,14 +77,14 @@
 # DIS-NEXT:     jr t3
 
 ## 32-bit: &.got.plt[bar]-. = 0x13070-0x11050 = 4096*2+32
-# DIS:        11050: auipc t3, 0x2
+# DIS:        20050: auipc t3, 0x2
 # DIS32-NEXT:   lw t3, 0x20(t3)
 # DIS64-NEXT:   ld t3, 0x90(t3)
 # DIS-NEXT:     jalr t1, t3
 # DIS-NEXT:     nop
 
 ## 32-bit: &.got.plt[weak]-. = 0x13074-0x11060 = 4096*2+20
-# DIS:        11060: auipc t3, 0x2
+# DIS:        20060: auipc t3, 0x2
 # DIS32-NEXT:   lw t3, 0x14(t3)
 # DIS64-NEXT:   ld t3, 0x88(t3)
 # DIS-NEXT:     jalr t1, t3
diff --git a/lld/test/ELF/riscv-reloc-copy.s b/lld/test/ELF/riscv-reloc-copy.s
index 17a5902cc4733..e8384cb531e4d 100644
--- a/lld/test/ELF/riscv-reloc-copy.s
+++ b/lld/test/ELF/riscv-reloc-copy.s
@@ -14,11 +14,11 @@
 # RUN: llvm-nm -S %t | FileCheck --check-prefix=NM64 %s
 
 # REL:        .rela.dyn {
-# REL32-NEXT:   0x13210 R_RISCV_COPY x 0x0
-# REL64-NEXT:   0x13360 R_RISCV_COPY x 0x0
+# REL32-NEXT:   0x40210 R_RISCV_COPY x 0x0
+# REL64-NEXT:   0x40360 R_RISCV_COPY x 0x0
 # REL-NEXT:   }
 
-# NM32: 00013210 00000004 B x
-# NM64: 0000000000013360 0000000000000004 B x
+# NM32: 00040210 00000004 B x
+# NM64: 0000000000040360 0000000000000004 B x
 
 la a0, x
diff --git a/lld/test/ELF/riscv-reloc-got.s b/lld/test/ELF/riscv-reloc-got.s
index 23b763ae507cf..137ce9840d9c0 100644
--- a/lld/test/ELF/riscv-reloc-got.s
+++ b/lld/test/ELF/riscv-reloc-got.s
@@ -21,42 +21,42 @@
 # RUN: llvm-readobj -x .got %t | FileCheck --check-prefix=HEX64 %s
 # RUN: llvm-objdump -d --no-show-raw-insn %t | FileCheck --check-prefix=DIS64 %s
 
-# SEC32: .got PROGBITS         0001220c 00020c 00000c
-# SEC64: .got PROGBITS 0000000000012358 000358 000018
+# SEC32: .got PROGBITS         0003020c 00020c 00000c
+# SEC64: .got PROGBITS 0000000000030358 000358 000018
 
 # RELOC32:      .rela.dyn {
-# RELOC32-NEXT:   0x12210 R_RISCV_32 b 0x0
+# RELOC32-NEXT:   0x30210 R_RISCV_32 b 0x0
 # RELOC32-NEXT: }
 
 # RELOC64:      .rela.dyn {
-# RELOC64-NEXT:   0x12360 R_RISCV_64 b 0x0
+# RELOC64-NEXT:   0x30360 R_RISCV_64 b 0x0
 # RELOC64-NEXT: }
 
-# NM32: 00013218 d a
-# NM64: 0000000000013370 d a
+# NM32: 00040218 d a
+# NM64: 0000000000040370 d a
 
 ## .got[0] = _DYNAMIC
 ## .got[1] = 0 (relocated by R_RISCV_32/64 at runtime)
 ## .got[2] = a (filled at link time)
 # HEX32: section '.got':
-# HEX32: 0x0001220c ac210100 00000000 18320100 
+# HEX32: 0x0003020c ac010300 00000000 18020400 
 
 # HEX64: section '.got':
-# HEX64: 0x00012358 98220100 00000000 00000000 00000000
-# HEX64: 0x00012368 70330100 00000000
+# HEX64: 0x00030358 98020300 00000000 00000000 00000000
+# HEX64: 0x00030368 70030400 00000000
 
 ## &.got[2]-. = 0x12214-0x1119c = 4096*1+120
-# DIS32:      1119c: auipc a0, 0x1
+# DIS32:      2019c: auipc a0, 0x1
 # DIS32-NEXT:        lw a0, 0x78(a0)
 ## &.got[1]-. = 0x12210-0x111a4 = 4096*1+108
-# DIS32:      111a4: auipc a0, 0x1
+# DIS32:      201a4: auipc a0, 0x1
 # DIS32-NEXT:        lw a0, 0x6c(a0)
 
 ## &.got[2]-. = 0x12368-0x11288 = 4096*1+224
-# DIS64:      11288: auipc a0, 0x1
+# DIS64:      20288: auipc a0, 0x1
 # DIS64-NEXT:        ld a0, 0xe0(a0)
 ## &.got[1]-. = 0x12360-0x11290 = 4096*1+208
-# DIS64:      11290: auipc a0, 0x1
+# DIS64:      20290: auipc a0, 0x1
 # DIS64-NEXT:        ld a0, 0xd0(a0)
 
 la a0,a
diff --git a/lld/test/ELF/riscv-tls-gd.s b/lld/test/ELF/riscv-tls-gd.s
index 767243c8ee46d..6523849092ac3 100644
--- a/lld/test/ELF/riscv-tls-gd.s
+++ b/lld/test/ELF/riscv-tls-gd.s
@@ -46,39 +46,39 @@
 # RUN: llvm-readelf -x .got %t.64 | FileCheck --check-prefix=IE64-GOT %s
 
 # GD32-REL:      .rela.dyn {
-# GD32-REL-NEXT:   0x2314 R_RISCV_TLS_DTPMOD32 a 0x0
-# GD32-REL-NEXT:   0x2318 R_RISCV_TLS_DTPREL32 a 0x0
-# GD32-REL-NEXT:   0x231C R_RISCV_TLS_DTPMOD32 b 0x0
-# GD32-REL-NEXT:   0x2320 R_RISCV_TLS_DTPREL32 b 0x0
+# GD32-REL-NEXT:   0x20314 R_RISCV_TLS_DTPMOD32 a 0x0
+# GD32-REL-NEXT:   0x20318 R_RISCV_TLS_DTPREL32 a 0x0
+# GD32-REL-NEXT:   0x2031C R_RISCV_TLS_DTPMOD32 b 0x0
+# GD32-REL-NEXT:   0x20320 R_RISCV_TLS_DTPREL32 b 0x0
 # GD32-REL-NEXT: }
 
 ## &DTPMOD(a) - . = 0x2314 - 0x1250 = 4096*1+196
-# GD32:      1250: auipc a0, 0x1
+# GD32:      10250: auipc a0, 0x1
 # GD32-NEXT:       addi a0, a0, 0xc4
 # GD32-NEXT:       auipc ra, 0x0
 # GD32-NEXT:       jalr 0x38(ra)
 
 ## &DTPMOD(b) - . = 0x231C - 0x1260 = 4096*1+188
-# GD32:      1260: auipc a0, 0x1
+# GD32:      10260: auipc a0, 0x1
 # GD32-NEXT:       addi a0, a0, 0xbc
 # GD32-NEXT:       auipc ra, 0x0
 # GD32-NEXT:       jalr 0x28(ra)
 
 # GD64-REL:      .rela.dyn {
-# GD64-REL-NEXT:   0x24D8 R_RISCV_TLS_DTPMOD64 a 0x0
-# GD64-REL-NEXT:   0x24E0 R_RISCV_TLS_DTPREL64 a 0x0
-# GD64-REL-NEXT:   0x24E8 R_RISCV_TLS_DTPMOD64 b 0x0
-# GD64-REL-NEXT:   0x24F0 R_RISCV_TLS_DTPREL64 b 0x0
+# GD64-REL-NEXT:   0x204D8 R_RISCV_TLS_DTPMOD64 a 0x0
+# GD64-REL-NEXT:   0x204E0 R_RISCV_TLS_DTPREL64 a 0x0
+# GD64-REL-NEXT:   0x204E8 R_RISCV_TLS_DTPMOD64 b 0x0
+# GD64-REL-NEXT:   0x204F0 R_RISCV_TLS_DTPREL64 b 0x0
 # GD64-REL-NEXT: }
 
 ## &DTPMOD(a) - . = 0x24d8 - 0x1398 = 4096*1+320
-# GD64:      1398: auipc a0, 0x1
+# GD64:      10398: auipc a0, 0x1
 # GD64-NEXT:       addi a0, a0, 0x140
 # GD64-NEXT:       auipc ra, 0x0
 # GD64-NEXT:       jalr 0x40(ra)
 
 ## &DTPMOD(b) - . = 0x24e8 - 0x13a8 = 4096*1+320
-# GD64:      13a8: auipc a0, 0x1
+# GD64:      103a8: auipc a0, 0x1
 # GD64-NEXT:       addi a0, a0, 0x140
 # GD64-NEXT:       auipc ra, 0x0
 # GD64-NEXT:       jalr 0x30(ra)
@@ -99,21 +99,21 @@
 ## a is local - relaxed to LE - its DTPMOD/DTPREL slots are link-time constants.
 ## b is external - DTPMOD/DTPREL dynamic relocations are required.
 # IE32-REL:      .rela.dyn {
-# IE32-REL-NEXT:   0x12234 R_RISCV_TLS_DTPMOD32 b 0x0
-# IE32-REL-NEXT:   0x12238 R_RISCV_TLS_DTPREL32 b 0x0
+# IE32-REL-NEXT:   0x30234 R_RISCV_TLS_DTPMOD32 b 0x0
+# IE32-REL-NEXT:   0x30238 R_RISCV_TLS_DTPREL32 b 0x0
 # IE32-REL-NEXT: }
 # IE32-GOT:      section '.got':
-# IE32-GOT-NEXT: 0x00012228 c8210100 01000000 08f8ffff 00000000
-# IE32-GOT-NEXT: 0x00012238 00000000
+# IE32-GOT-NEXT: 0x00030228 c8010300 01000000 08f8ffff 00000000
+# IE32-GOT-NEXT: 0x00030238 00000000
 
 # IE64-REL:      .rela.dyn {
-# IE64-REL-NEXT:   0x12398 R_RISCV_TLS_DTPMOD64 b 0x0
-# IE64-REL-NEXT:   0x123A0 R_RISCV_TLS_DTPREL64 b 0x0
+# IE64-REL-NEXT:   0x30398 R_RISCV_TLS_DTPMOD64 b 0x0
+# IE64-REL-NEXT:   0x303A0 R_RISCV_TLS_DTPREL64 b 0x0
 # IE64-REL-NEXT: }
 # IE64-GOT:      section '.got':
-# IE64-GOT-NEXT: 0x00012380 c0220100 00000000 01000000 00000000
-# IE64-GOT-NEXT: 0x00012390 08f8ffff ffffffff 00000000 00000000
-# IE64-GOT-NEXT: 0x000123a0 00000000 00000000
+# IE64-GOT-NEXT: 0x00030380 c0020300 00000000 01000000 00000000
+# IE64-GOT-NEXT: 0x00030390 08f8ffff ffffffff 00000000 00000000
+# IE64-GOT-NEXT: 0x000303a0 00000000 00000000
 
 la.tls.gd a0,a
 call __tls_get_addr at plt
diff --git a/lld/test/ELF/riscv-tls-ie.s b/lld/test/ELF/riscv-tls-ie.s
index b513aa841f6c9..5bc051ab1f874 100644
--- a/lld/test/ELF/riscv-tls-ie.s
+++ b/lld/test/ELF/riscv-tls-ie.s
@@ -24,14 +24,14 @@
 
 # IE32-REL:      FLAGS STATIC_TLS
 # IE32-REL:      .rela.dyn {
-# IE32-REL-NEXT:   0x221C R_RISCV_TLS_TPREL32 - 0xC
-# IE32-REL-NEXT:   0x2218 R_RISCV_TLS_TPREL32 a 0x0
+# IE32-REL-NEXT:   0x2021C R_RISCV_TLS_TPREL32 - 0xC
+# IE32-REL-NEXT:   0x20218 R_RISCV_TLS_TPREL32 a 0x0
 # IE32-REL-NEXT: }
 
 # IE64-REL:      FLAGS STATIC_TLS
 # IE64-REL:      .rela.dyn {
-# IE64-REL-NEXT:   0x2378 R_RISCV_TLS_TPREL64 - 0xC
-# IE64-REL-NEXT:   0x2370 R_RISCV_TLS_TPREL64 a 0x0
+# IE64-REL-NEXT:   0x20378 R_RISCV_TLS_TPREL64 - 0xC
+# IE64-REL-NEXT:   0x20370 R_RISCV_TLS_TPREL64 a 0x0
 # IE64-REL-NEXT: }
 
 ## rv32: &.got[0] - . = 0x2218 - . = 4096*1+116
@@ -52,23 +52,23 @@
 # a at tprel = st_value(a) = 0x8
 # b at tprel = st_value(a) = 0xc
 # LE32-GOT: section '.got':
-# LE32-GOT-NEXT: 0x0001212c 00000000 08000000 0c000000
+# LE32-GOT-NEXT: 0x0003012c 00000000 08000000 0c000000
 # LE64-GOT: section '.got':
-# LE64-GOT-NEXT: 0x000121e0 00000000 00000000 08000000 00000000
-# LE64-GOT-NEXT: 0x000121f0 0c000000 00000000
+# LE64-GOT-NEXT: 0x000301e0 00000000 00000000 08000000 00000000
+# LE64-GOT-NEXT: 0x000301f0 0c000000 00000000
 
 ## rv32: &.got[0] - . = 0x12130 - 0x11114 = 4096*1+28
 ## rv64: &.got[0] - . = 0x121e8 - 0x111c8 = 4096*1+32
-# LE32:      11114: auipc a4, 0x1
+# LE32:      20114: auipc a4, 0x1
 # LE32-NEXT:        lw a4, 0x1c(a4)
-# LE64:      111c8: auipc a4, 0x1
+# LE64:      201c8: auipc a4, 0x1
 # LE64-NEXT:        ld a4, 0x20(a4)
 # LE-NEXT:          add a4, a4, tp
 ## rv32: &.got[1] - . = 0x12134 - 0x11120 = 4096*1+20
 ## rv64: &.got[1] - . = 0x121f0 - 0x111d4 = 4096*1+28
-# LE32:      11120: auipc a5, 0x1
+# LE32:      20120: auipc a5, 0x1
 # LE32-NEXT:        lw a5, 0x14(a5)
-# LE64:      111d4: auipc a5, 0x1
+# LE64:      201d4: auipc a5, 0x1
 # LE64-NEXT:        ld a5, 0x1c(a5)
 # LE-NEXT:          add a5, a5, tp
 
diff --git a/lld/test/ELF/riscv-tls-ld.s b/lld/test/ELF/riscv-tls-ld.s
index b40a589779c4a..2d05747bb1e8b 100644
--- a/lld/test/ELF/riscv-tls-ld.s
+++ b/lld/test/ELF/riscv-tls-ld.s
@@ -35,25 +35,25 @@
 
 ## a at dtprel = st_value(a)-0x800 = 0xfffff808 is a link-time constant.
 # LD32-REL:      .rela.dyn {
-# LD32-REL-NEXT:   0x22AC
-# LD32-REL-NEXT:   0x22B0 R_RISCV_TLS_DTPMOD32 - 0x0
+# LD32-REL-NEXT:   0x202AC
+# LD32-REL-NEXT:   0x202B0 R_RISCV_TLS_DTPMOD32 - 0x0
 # LD32-REL-NEXT: }
 # LD32-GOT:      section '.got':
-# LD32-GOT-NEXT: 0x000022a8 30220000 00000000 00000000 00f8ffff
+# LD32-GOT-NEXT: 0x000202a8 30020200 00000000 00000000 00f8ffff
 
 # LD64-REL:      .rela.dyn {
-# LD64-REL-NEXT:   0x2448
-# LD64-REL-NEXT:   0x2450 R_RISCV_TLS_DTPMOD64 - 0x0
+# LD64-REL-NEXT:   0x20448
+# LD64-REL-NEXT:   0x20450 R_RISCV_TLS_DTPMOD64 - 0x0
 # LD64-REL-NEXT: }
 # LD64-GOT:      section '.got':
-# LD64-GOT-NEXT: 0x00002440 50230000 00000000 00000000 00000000
-# LD64-GOT-NEXT: 0x00002450 00000000 00000000 00f8ffff ffffffff
+# LD64-GOT-NEXT: 0x00020440 50030200 00000000 00000000 00000000
+# LD64-GOT-NEXT: 0x00020450 00000000 00000000 00f8ffff ffffffff
 
 ## rv32: &DTPMOD(a) - . = 0x22b0 - 0x11d8 = 4096*1+216
 ## rv64: &DTPMOD(a) - . = 0x2450 - 0x12f8 = 4096*1+344
-# LD32:      11d8: auipc a0, 0x1
+# LD32:      101d8: auipc a0, 0x1
 # LD32-NEXT:       addi a0, a0, 0xd8
-# LD64:      12f8: auipc a0, 0x1
+# LD64:      102f8: auipc a0, 0x1
 # LD64-NEXT:       addi a0, a0, 0x158
 # LD-NEXT:         auipc ra, 0x0
 # LD-NEXT:         jalr 0x40(ra)
@@ -63,17 +63,17 @@
 ## a is local - its DTPMOD/DTPREL slots are link-time constants.
 ## a at dtpmod = 1 (main module)
 # LE32-GOT: section '.got':
-# LE32-GOT-NEXT: 0x00012134 00000000 34210100 01000000 00f8ffff
+# LE32-GOT-NEXT: 0x00030134 00000000 34010300 01000000 00f8ffff
 
 # LE64-GOT: section '.got':
-# LE64-GOT-NEXT: 0x000121e8 00000000 00000000 e8210100 00000000
-# LE64-GOT-NEXT: 0x000121f8 01000000 00000000 00f8ffff ffffffff
+# LE64-GOT-NEXT: 0x000301e8 00000000 00000000 e8010300 00000000
+# LE64-GOT-NEXT: 0x000301f8 01000000 00000000 00f8ffff ffffffff
 
 ## rv32: DTPMOD(.LANCHOR0) - . = 0x1213c - 0x11114 = 4096*1+40
 ## rv64: DTPMOD(.LANCHOR0) - . = 0x121f8 - 0x111c8 = 4096*1+48
-# LE32:      11114: auipc a0, 0x1
+# LE32:      20114: auipc a0, 0x1
 # LE32-NEXT:        addi a0, a0, 0x28
-# LE64:      111c8: auipc a0, 0x1
+# LE64:      201c8: auipc a0, 0x1
 # LE64-NEXT:        addi a0, a0, 0x30
 # LE-NEXT:          auipc ra, 0x0
 # LE-NEXT:          jalr 0x18(ra)
diff --git a/lld/test/ELF/riscv-tlsdesc-relax.s b/lld/test/ELF/riscv-tlsdesc-relax.s
index 5718d4175be11..d72e52492f88f 100644
--- a/lld/test/ELF/riscv-tlsdesc-relax.s
+++ b/lld/test/ELF/riscv-tlsdesc-relax.s
@@ -18,12 +18,12 @@
 # RUN: ld.lld -e 0 -z now a.64.o c.64.so -o a.64.ie -z separate-code
 # RUN: llvm-objdump --no-show-raw-insn -M no-aliases -h -d a.64.ie | FileCheck %s --check-prefix=IE64
 
-# GD64:      .got     00000018 00000000000020c0
+# GD64:      .got     00000018 00000000000200c0
 # GD64-LABEL: <_start>:
 # GD64-NEXT:         jal     {{.*}} <foo>
 # GD64-LABEL: <foo>:
 ## &.got[c]-. = 0x20c0+8 - 0x1004 = 0x10c4
-# GD64:        1004: auipc   a2, 0x1
+# GD64:        10004: auipc   a2, 0x1
 # GD64-NEXT:         c.add   a7, a7
 # GD64-NEXT:         ld      a3, 0xc4(a2)
 # GD64-NEXT:         c.add   a7, a7
@@ -34,14 +34,14 @@
 # GD64-NEXT:         jal     {{.*}} <foo>
 ## &.got[c]-. = 0x20c0+8 - 0x1020 = 0x10a8
 # GD64-LABEL: <.Ltlsdesc_hi1>:
-# GD64-NEXT:   1020: auipc   a4, 0x1
+# GD64-NEXT:   10020: auipc   a4, 0x1
 # GD64-NEXT:         ld      a5, 0xa8(a4)
 # GD64-NEXT:         addi    a0, a4, 0xa8
 # GD64-NEXT:         jalr    t0, 0x0(a5)
 # GD64-NEXT:         c.add   a0, tp
 ## &.got[c]-. = 0x20c0+8 - 0x1032 = 0x1096
 # GD64-LABEL: <.Ltlsdesc_hi2>:
-# GD64-NEXT:   1032: auipc   a6, 0x1
+# GD64-NEXT:   10032: auipc   a6, 0x1
 # GD64-NEXT:         ld      a7, 0x96(a6)
 # GD64-NEXT:         addi    a0, a6, 0x96
 # GD64-NEXT:         jalr    t0, 0x0(a7)
@@ -56,7 +56,7 @@
 # LE64-NEXT:         c.add   a7, a7
 # LE64-NEXT:                 R_RISCV_TLSDESC_LOAD_LO12 .Ltlsdesc_hi0
 # LE64-NEXT:                 R_RISCV_RELAX *ABS*
-# LE64-NEXT:  11008: c.add   a7, a7
+# LE64-NEXT:  20008: c.add   a7, a7
 # LE64-NEXT:                 R_RISCV_TLSDESC_ADD_LO12 .Ltlsdesc_hi0
 # LE64-NEXT:                 R_RISCV_RELAX *ABS*
 # LE64-NEXT:         addi    a0, zero, 0x7ff
@@ -92,7 +92,7 @@
 # LE64A-LABEL: <foo>:
 # LE64A-NEXT:         c.add   a7, a7
 # LE64A-NEXT:         c.add   a7, a7
-# LE64A-NEXT:  11008: lui     a0, 0x2
+# LE64A-NEXT:  20008: lui     a0, 0x2
 # LE64A-NEXT:         c.add   a7, a7
 # LE64A-NEXT:         addi    a0, a0, -0x479
 # LE64A-NEXT:         c.add   a0, tp
@@ -108,28 +108,28 @@
 # LE64A-NEXT:         addi    a0, a0, -0x479
 # LE64A-NEXT:         c.add   a0, tp
 
-# IE64:       .got     00000010 00000000000120e0
+# IE64:       .got     00000010 00000000000300e0
 # IE64-LABEL: <_start>:
 # IE64-NEXT:         jal     {{.*}} <foo>
 # IE64-LABEL: <foo>:
 # IE64-NEXT:         c.add   a7, a7
 # IE64-NEXT:         c.add   a7, a7
 ## &.got[c]-. = 0x120e0+8 - 0x11008 = 0x10e0
-# IE64-NEXT:  11008: auipc   a0, 0x1
+# IE64-NEXT:  20008: auipc   a0, 0x1
 # IE64-NEXT:         c.add   a7, a7
 # IE64-NEXT:         ld      a0, 0xe0(a0)
 # IE64-NEXT:         c.add   a0, tp
 # IE64-NEXT:         jal     {{.*}} <foo>
 ## &.got[c]-. = 0x120e0+8 - 0x11018 = 0x10d0
 # IE64-LABEL: <.Ltlsdesc_hi1>:
-# IE64-NEXT:  11018: auipc   a0, 0x1
+# IE64-NEXT:  20018: auipc   a0, 0x1
 # IE64-NEXT:         ld      a0, 0xd0(a0)
 # IE64-NEXT:         c.add   a0, tp
 ## &.got[c]-. = 0x120e0+8 - 0x1102a = 0x10be
 # IE64-LABEL: <.Ltlsdesc_hi2>:
 # IE64-NEXT:         addi    zero, zero, 0x0
 # IE64-NEXT:         addi    zero, zero, 0x0
-# IE64-NEXT:  1102a: auipc   a0, 0x1
+# IE64-NEXT:  2002a: auipc   a0, 0x1
 # IE64-NEXT:         ld      a0, 0xbe(a0)
 # IE64-NEXT:         c.add   a0, tp
 
diff --git a/lld/test/ELF/riscv-tlsdesc.s b/lld/test/ELF/riscv-tlsdesc.s
index 6c0dd9a247a4e..adeebc7dc3513 100644
--- a/lld/test/ELF/riscv-tlsdesc.s
+++ b/lld/test/ELF/riscv-tlsdesc.s
@@ -43,52 +43,52 @@
 # RUN: llvm-objdump --no-show-raw-insn -M no-aliases -Rd a1.64 | FileCheck %s --check-prefix=IE64A
 
 # GD64-RELA:      .rela.dyn {
-# GD64-RELA-NEXT:   0x2408 R_RISCV_TLSDESC - 0x7FF
-# GD64-RELA-NEXT:   0x23E8 R_RISCV_TLSDESC a 0x0
-# GD64-RELA-NEXT:   0x23F8 R_RISCV_TLSDESC c 0x0
+# GD64-RELA-NEXT:   0x20408 R_RISCV_TLSDESC - 0x7FF
+# GD64-RELA-NEXT:   0x203E8 R_RISCV_TLSDESC a 0x0
+# GD64-RELA-NEXT:   0x203F8 R_RISCV_TLSDESC c 0x0
 # GD64-RELA-NEXT: }
 # GD64-RELA:      Hex dump of section '.got':
-# GD64-RELA-NEXT: 0x000023e0 20230000 00000000 00000000 00000000 #
-# GD64-RELA-NEXT: 0x000023f0 00000000 00000000 00000000 00000000 .
+# GD64-RELA-NEXT: 0x000203e0 20030200 00000000 00000000 00000000 .
+# GD64-RELA-NEXT: 0x000203f0 00000000 00000000 00000000 00000000 .
 
 # GD64-REL:      .rel.dyn {
-# GD64-REL-NEXT:   0x23F0 R_RISCV_TLSDESC -
-# GD64-REL-NEXT:   0x23D0 R_RISCV_TLSDESC a
-# GD64-REL-NEXT:   0x23E0 R_RISCV_TLSDESC c
+# GD64-REL-NEXT:   0x203F0 R_RISCV_TLSDESC -
+# GD64-REL-NEXT:   0x203D0 R_RISCV_TLSDESC a
+# GD64-REL-NEXT:   0x203E0 R_RISCV_TLSDESC c
 # GD64-REL-NEXT: }
 # GD64-REL:      Hex dump of section '.got':
-# GD64-REL-NEXT: 0x000023c8 08230000 00000000 00000000 00000000 .
-# GD64-REL-NEXT: 0x000023d8 00000000 00000000 00000000 00000000 .
-# GD64-REL-NEXT: 0x000023e8 00000000 00000000 00000000 00000000 .
-# GD64-REL-NEXT: 0x000023f8 ff070000 00000000                   .
+# GD64-REL-NEXT: 0x000203c8 08030200 00000000 00000000 00000000 .
+# GD64-REL-NEXT: 0x000203d8 00000000 00000000 00000000 00000000 .
+# GD64-REL-NEXT: 0x000203e8 00000000 00000000 00000000 00000000 .
+# GD64-REL-NEXT: 0x000203f8 ff070000 00000000                   .
 
 # GD32-REL:      .rel.dyn {
-# GD32-REL-NEXT:   0x2274 R_RISCV_TLSDESC -
-# GD32-REL-NEXT:   0x2264 R_RISCV_TLSDESC a
-# GD32-REL-NEXT:   0x226C R_RISCV_TLSDESC c
+# GD32-REL-NEXT:   0x20274 R_RISCV_TLSDESC -
+# GD32-REL-NEXT:   0x20264 R_RISCV_TLSDESC a
+# GD32-REL-NEXT:   0x2026C R_RISCV_TLSDESC c
 # GD32-REL-NEXT: }
 # GD32-REL:      Hex dump of section '.got':
-# GD32-REL-NEXT: 0x00002260 00220000 00000000 00000000 00000000 .
-# GD32-REL-NEXT: 0x00002270 00000000 00000000 ff070000          .
+# GD32-REL-NEXT: 0x00020260 00020200 00000000 00000000 00000000 .
+# GD32-REL-NEXT: 0x00020270 00000000 00000000 ff070000          .
 
-# GD64:      .got     00000038 00000000000023e0
+# GD64:      .got     00000038 00000000000203e0
 
 ## &.got[a]-. = 0x23e0+8 - 0x12e0 = 0x1108
-# GD64:        12e0: auipc   a0, 0x1
+# GD64:        102e0: auipc   a0, 0x1
 # GD64-NEXT:         ld      a1, 0x108(a0)
 # GD64-NEXT:         addi    a0, a0, 0x108
 # GD64-NEXT:         jalr    t0, 0x0(a1)
 # GD64-NEXT:         add     a0, a0, tp
 
 ## &.got[b]-. = 0x23e0+40 - 0x12f4 = 0x1114
-# GD64:        12f4: auipc   a2, 0x1
+# GD64:        102f4: auipc   a2, 0x1
 # GD64-NEXT:         ld      a3, 0x114(a2)
 # GD64-NEXT:         addi    a0, a2, 0x114
 # GD64-NEXT:         jalr    t0, 0x0(a3)
 # GD64-NEXT:         add     a0, a0, tp
 
 ## &.got[c]-. = 0x23e0+24 - 0x1308 = 0x10f0
-# GD64:        1308: auipc   a4, 0x1
+# GD64:        10308: auipc   a4, 0x1
 # GD64-NEXT:         ld      a5, 0xf0(a4)
 # GD64-NEXT:         addi    a0, a4, 0xf0
 # GD64-NEXT:         jalr    t0, 0x0(a5)
@@ -119,10 +119,10 @@
 # LE64-NEXT:         add     a0, a0, tp
 
 # IE64-RELA:      .rela.dyn {
-# IE64-RELA-NEXT:   0x123B0 R_RISCV_TLS_TPREL64 c 0x0
+# IE64-RELA-NEXT:   0x303B0 R_RISCV_TLS_TPREL64 c 0x0
 # IE64-RELA-NEXT: }
 
-# IE64:       .got     00000010 00000000000123a8
+# IE64:       .got     00000010 00000000000303a8
 
 ## a and b are optimized to use LE. c is optimized to IE.
 # IE64-LABEL: <.Ltlsdesc_hi0>:
@@ -141,11 +141,11 @@
 # IE64-LABEL: <.Ltlsdesc_hi2>:
 # IE64-NEXT:         addi    zero, zero, 0x0
 # IE64-NEXT:         addi    zero, zero, 0x0
-# IE64-NEXT:  112b8: auipc   a0, 0x1
+# IE64-NEXT:  202b8: auipc   a0, 0x1
 # IE64-NEXT:         ld      a0, 0xf8(a0)
 # IE64-NEXT:         add     a0, a0, tp
 
-# IE32:       .got     00000008 00012248
+# IE32:       .got     00000008 00030248
 
 # IE32-LABEL: <.Ltlsdesc_hi0>:
 ## st_value(a) = 8
@@ -165,18 +165,18 @@
 # IE32-LABEL: <.Ltlsdesc_hi2>:
 # IE32-NEXT:         addi    zero, zero, 0x0
 # IE32-NEXT:         addi    zero, zero, 0x0
-# IE32-NEXT:  111cc: auipc   a0, 0x1
+# IE32-NEXT:  201cc: auipc   a0, 0x1
 # IE32-NEXT:         lw      a0, 0x80(a0)
 # IE32-NEXT:         add     a0, a0, tp
 
 # IE64A:       OFFSET           TYPE                     VALUE
-# IE64A-NEXT:  0000000000002340 R_RISCV_TLS_TPREL64      c
+# IE64A-NEXT:  0000000000020340 R_RISCV_TLS_TPREL64      c
 # IE64A-EMPTY:
 ## &.got[c]-. = 0x2340 - 0x1258 = 0x10e8
 # IE64A-LABEL: <.Ltlsdesc_hi2>:
 # IE64A-NEXT:         addi    zero, zero, 0x0
 # IE64A-NEXT:         addi    zero, zero, 0x0
-# IE64A-NEXT:   1258: auipc   a0, 0x1
+# IE64A-NEXT:   10258: auipc   a0, 0x1
 # IE64A-NEXT:         ld      a0, 0xe8(a0)
 # IE64A-NEXT:         add     a0, a0, tp
 
diff --git a/lld/test/ELF/riscv-undefined-weak.s b/lld/test/ELF/riscv-undefined-weak.s
index 8a78e1f838338..c57f8507a3a86 100644
--- a/lld/test/ELF/riscv-undefined-weak.s
+++ b/lld/test/ELF/riscv-undefined-weak.s
@@ -34,11 +34,11 @@ absolute:
 
 ## 1048559 should be -0x11.
 # CHECK-LABEL: <relative>:
-# CHECK-NEXT:  11{{...}}: auipc a1, 0xfffef
+# CHECK-NEXT:  20{{...}}: auipc a1, 0xfffe0
 # PC-NEXT:     addi a1, a1, -0x160
 # PLT-NEXT:    addi a1, a1, -0x290
 # CHECK-LABEL: <.Lpcrel_hi1>:
-# CHECK-NEXT:  11{{...}}: auipc t1, 0xfffef
+# CHECK-NEXT:  20{{...}}: auipc t1, 0xfffe0
 # PC-NEXT:     sd a2, -0x166(t1)
 # PLT-NEXT:    sd a2, -0x296(t1)
 relative:
@@ -87,7 +87,7 @@ branch:
 ## plt entry and this address.
 ##
 ##   S - A + P = -0x0x20ec = 0xffffdf14
-# HEX-WITH-PLT-SAME: 14dfffff
+# HEX-WITH-PLT-SAME: 14fffdff
 
 .data
 .p2align 3
diff --git a/lld/test/ELF/riscv32-reloc-32-pic.s b/lld/test/ELF/riscv32-reloc-32-pic.s
index 72bb16f12b0bd..4c9e22ba232aa 100644
--- a/lld/test/ELF/riscv32-reloc-32-pic.s
+++ b/lld/test/ELF/riscv32-reloc-32-pic.s
@@ -7,11 +7,11 @@
 ## R_RISCV_32 is an absolute relocation type.
 ## In PIC mode, it creates a relative relocation if the symbol is non-preemptable.
 
-# NM: 000031fc d b
+# NM: 000301fc d b
 
 # RELOC:      .rela.dyn {
-# RELOC-NEXT:   0x31FC R_RISCV_RELATIVE - 0x31FC
-# RELOC-NEXT:   0x31F8 R_RISCV_32 a 0
+# RELOC-NEXT:   0x301FC R_RISCV_RELATIVE - 0x301FC
+# RELOC-NEXT:   0x301F8 R_RISCV_32 a 0
 # RELOC-NEXT: }
 
 .globl a, b
diff --git a/lld/test/ELF/riscv64-reloc-64-pic.s b/lld/test/ELF/riscv64-reloc-64-pic.s
index 793d17f056b48..463bb8fad1e76 100644
--- a/lld/test/ELF/riscv64-reloc-64-pic.s
+++ b/lld/test/ELF/riscv64-reloc-64-pic.s
@@ -7,11 +7,11 @@
 ## R_RISCV_64 is an absolute relocation type.
 ## In PIC mode, it creates a relative relocation if the symbol is non-preemptable.
 
-# NM: 0000000000003350 d b
+# NM: 0000000000030350 d b
 
 # RELOC:      .rela.dyn {
-# RELOC-NEXT:   0x3350 R_RISCV_RELATIVE - 0x3350
-# RELOC-NEXT:   0x3348 R_RISCV_64 a 0
+# RELOC-NEXT:   0x30350 R_RISCV_RELATIVE - 0x30350
+# RELOC-NEXT:   0x30348 R_RISCV_64 a 0
 # RELOC-NEXT: }
 
 .globl a, b
diff --git a/lld/test/ELF/riscv64-reloc-got32-pcrel.s b/lld/test/ELF/riscv64-reloc-got32-pcrel.s
index 24bd828235b25..776f3ab3bb5a0 100644
--- a/lld/test/ELF/riscv64-reloc-got32-pcrel.s
+++ b/lld/test/ELF/riscv64-reloc-got32-pcrel.s
@@ -4,7 +4,7 @@
 // RUN: llvm-readelf -S %t.so | FileCheck --check-prefix=SEC %s
 // RUN: llvm-objdump --no-print-imm-hex -s -d %t.so | FileCheck %s
 
-// SEC: .got PROGBITS 0000000000002390
+// SEC: .got PROGBITS 0000000000020390
 
   .section .data
   .globl bar
@@ -16,7 +16,7 @@ _start:  // PC = 0x33a8
 // bar at GOTPCREL+4 = 0x2398 (got entry for `bar`) - 0x33ac (.) + 4 = 0xf0efffff
 // bar at GOTPCREL-4 = 0x2398 (got entry for `bar`) - 0x33b0 (.) - 4 = 0xe4efffff
 // CHECK:      Contents of section .data:
-// CHECK-NEXT:  {{.*}} f0efffff f0efffff e4efffff
+// CHECK-NEXT:  {{.*}} f0fffeff f0fffeff e4fffeff ebfffeff
   .word bar at GOTPCREL
   .word bar at GOTPCREL+4
   .word bar at GOTPCREL-4



More information about the llvm-commits mailing list