Skip to content

Commit 166483a

Browse files
uweigandtuliom
andcommitted
[lld] Add target support for SystemZ (s390x)
This patch adds full support for linking SystemZ (ELF s390x) object files. Support should be generally complete: - All relocation types are supported. - Full shared library support (DYNAMIC, GOT, PLT, ifunc). - Relaxation of TLS and GOT relocations where appropriate. - Platform-specific test cases. In addition to new platform code and the obvious changes, there were a few additional changes to common code: - Add three new RelExpr members (R_GOTPLT_OFF, R_GOTPLT_PC, and R_PLT_GOTREL) needed to support certain s390x relocations. I chose not to use a platform-specific name since nothing in the definition of these relocs is actually platform-specific; it is well possible that other platforms will need the same. - A couple of tweaks to TLS relocation handling, as the particular semantics of the s390x versions differ slightly. See comments in the code. This was tested by building and testing >1500 Fedora packages, with only a handful of failures; as these also have issues when building with LLD on other architectures, they seem unrelated. Co-authored-by: Tulio Magno Quites Machado Filho <tuliom@redhat.com>
1 parent 59f7f35 commit 166483a

38 files changed

+1881
-3
lines changed

lld/ELF/Arch/SystemZ.cpp

+587
Large diffs are not rendered by default.

lld/ELF/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ add_lld_library(lldELF
3333
Arch/PPC64.cpp
3434
Arch/RISCV.cpp
3535
Arch/SPARCV9.cpp
36+
Arch/SystemZ.cpp
3637
Arch/X86.cpp
3738
Arch/X86_64.cpp
3839
ARMErrataFix.cpp

lld/ELF/Driver.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ static std::tuple<ELFKind, uint16_t, uint8_t> parseEmulation(StringRef emul) {
199199
.Case("msp430elf", {ELF32LEKind, EM_MSP430})
200200
.Case("elf64_amdgpu", {ELF64LEKind, EM_AMDGPU})
201201
.Case("elf64loongarch", {ELF64LEKind, EM_LOONGARCH})
202+
.Case("elf64_s390", {ELF64BEKind, EM_S390})
202203
.Default({ELFNoneKind, EM_NONE});
203204

204205
if (ret.first == ELFNoneKind)
@@ -1171,7 +1172,7 @@ static bool getIsRela(opt::InputArgList &args) {
11711172
uint16_t m = config->emachine;
11721173
return m == EM_AARCH64 || m == EM_AMDGPU || m == EM_HEXAGON ||
11731174
m == EM_LOONGARCH || m == EM_PPC || m == EM_PPC64 || m == EM_RISCV ||
1174-
m == EM_X86_64;
1175+
m == EM_S390 || m == EM_X86_64;
11751176
}
11761177

11771178
static void parseClangOption(StringRef opt, const Twine &msg) {

lld/ELF/InputFiles.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -1612,6 +1612,8 @@ static uint16_t getBitcodeMachineKind(StringRef path, const Triple &t) {
16121612
return EM_RISCV;
16131613
case Triple::sparcv9:
16141614
return EM_SPARCV9;
1615+
case Triple::systemz:
1616+
return EM_S390;
16151617
case Triple::x86:
16161618
return t.isOSIAMCU() ? EM_IAMCU : EM_386;
16171619
case Triple::x86_64:

lld/ELF/InputSection.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ static int64_t getTlsTpOffset(const Symbol &s) {
652652

653653
// Variant 2.
654654
case EM_HEXAGON:
655+
case EM_S390:
655656
case EM_SPARCV9:
656657
case EM_386:
657658
case EM_X86_64:
@@ -705,6 +706,8 @@ uint64_t InputSectionBase::getRelocTargetVA(const InputFile *file, RelType type,
705706
case R_GOT_OFF:
706707
case R_RELAX_TLS_GD_TO_IE_GOT_OFF:
707708
return sym.getGotOffset() + a;
709+
case R_GOTPLT_OFF:
710+
return sym.getGotPltOffset() + a;
708711
case R_AARCH64_GOT_PAGE_PC:
709712
case R_AARCH64_RELAX_TLS_GD_TO_IE_PAGE_PC:
710713
return getAArch64Page(sym.getGotVA() + a) - getAArch64Page(p);
@@ -713,6 +716,8 @@ uint64_t InputSectionBase::getRelocTargetVA(const InputFile *file, RelType type,
713716
case R_GOT_PC:
714717
case R_RELAX_TLS_GD_TO_IE:
715718
return sym.getGotVA() + a - p;
719+
case R_GOTPLT_PC:
720+
return sym.getGotPltVA() + a - p;
716721
case R_LOONGARCH_GOT_PAGE_PC:
717722
if (sym.hasFlag(NEEDS_TLSGD))
718723
return getLoongArchPageDelta(in.got->getGlobalDynAddr(sym) + a, p);
@@ -804,6 +809,8 @@ uint64_t InputSectionBase::getRelocTargetVA(const InputFile *file, RelType type,
804809
return getLoongArchPageDelta(sym.getPltVA() + a, p);
805810
case R_PLT_GOTPLT:
806811
return sym.getPltVA() + a - in.gotPlt->getVA();
812+
case R_PLT_GOTREL:
813+
return sym.getPltVA() + a - in.got->getVA();
807814
case R_PPC32_PLTREL:
808815
// R_PPC_PLTREL24 uses the addend (usually 0 or 0x8000) to indicate r30
809816
// stores _GLOBAL_OFFSET_TABLE_ or .got2+0x8000. The addend is ignored for

lld/ELF/Relocations.cpp

+22-2
Original file line numberDiff line numberDiff line change
@@ -1357,8 +1357,8 @@ static unsigned handleTlsRelocation(RelType type, Symbol &sym,
13571357
R_LOONGARCH_GOT_PAGE_PC, R_GOT_OFF, R_TLSIE_HINT>(expr)) {
13581358
ctx.hasTlsIe.store(true, std::memory_order_relaxed);
13591359
// Initial-Exec relocs can be relaxed to Local-Exec if the symbol is locally
1360-
// defined.
1361-
if (toExecRelax && isLocalInExecutable) {
1360+
// defined. This is not supported on SystemZ.
1361+
if (toExecRelax && isLocalInExecutable && config->emachine != EM_S390) {
13621362
c.addReloc({R_RELAX_TLS_IE_TO_LE, type, offset, addend, &sym});
13631363
} else if (expr != R_TLSIE_HINT) {
13641364
sym.setFlags(NEEDS_TLSIE);
@@ -1404,6 +1404,26 @@ template <class ELFT, class RelTy> void RelocationScanner::scanOne(RelTy *&i) {
14041404
if (expr == R_NONE)
14051405
return;
14061406

1407+
// Like other platforms, calls to the TLS helper routine on SystemZ carry
1408+
// two relocations, one for the helper routine itself, and a TLS marker
1409+
// relocation. When relaxing the TLS model, the helper routine is no longer
1410+
// needed, and its relocation should be removed. Unlike other platforms,
1411+
// on SystemZ the TLS marker routine typically comes *after* the helper
1412+
// routine relocation, so the getTlsGdRelaxSkip mechanism used by
1413+
// handleTlsRelocation does not work on this platform.
1414+
//
1415+
// Instead, check for this case here: if we are building a main executable
1416+
// (i.e. TLS relaxation applies), and the relocation *after* the current one
1417+
// is a TLS call marker instruction matching the current instruction, then
1418+
// skip this relocation.
1419+
if (config->emachine == EM_S390 && !config->shared) {
1420+
if (i < end && getter.get(i->r_offset) == offset - 2) {
1421+
RelType nextType = i->getType(/*isMips64EL=*/false);
1422+
if (nextType == R_390_TLS_GDCALL || nextType == R_390_TLS_LDCALL)
1423+
return;
1424+
}
1425+
}
1426+
14071427
// Error if the target symbol is undefined. Symbol index 0 may be used by
14081428
// marker relocations, e.g. R_*_NONE and R_ARM_V4BX. Don't error on them.
14091429
if (sym.isUndefined() && symIndex != 0 &&

lld/ELF/Relocations.h

+3
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,14 @@ enum RelExpr {
4040
R_GOTPLT,
4141
R_GOTPLTREL,
4242
R_GOTREL,
43+
R_GOTPLT_OFF,
44+
R_GOTPLT_PC,
4345
R_NONE,
4446
R_PC,
4547
R_PLT,
4648
R_PLT_PC,
4749
R_PLT_GOTPLT,
50+
R_PLT_GOTREL,
4851
R_RELAX_HINT,
4952
R_RELAX_GOT_PC,
5053
R_RELAX_GOT_PC_NOPIC,

lld/ELF/ScriptParser.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,7 @@ static std::pair<ELFKind, uint16_t> parseBfdName(StringRef s) {
444444
.Case("elf32-msp430", {ELF32LEKind, EM_MSP430})
445445
.Case("elf32-loongarch", {ELF32LEKind, EM_LOONGARCH})
446446
.Case("elf64-loongarch", {ELF64LEKind, EM_LOONGARCH})
447+
.Case("elf64-s390", {ELF64BEKind, EM_S390})
447448
.Default({ELFNoneKind, EM_NONE});
448449
}
449450

lld/ELF/SyntheticSections.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -1419,6 +1419,9 @@ DynamicSection<ELFT>::computeContents() {
14191419
case EM_MIPS:
14201420
addInSec(DT_MIPS_PLTGOT, *in.gotPlt);
14211421
break;
1422+
case EM_S390:
1423+
addInSec(DT_PLTGOT, *in.got);
1424+
break;
14221425
case EM_SPARCV9:
14231426
addInSec(DT_PLTGOT, *in.plt);
14241427
break;

lld/ELF/Target.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ TargetInfo *elf::getTarget() {
8787
return getRISCVTargetInfo();
8888
case EM_SPARCV9:
8989
return getSPARCV9TargetInfo();
90+
case EM_S390:
91+
return getSystemZTargetInfo();
9092
case EM_X86_64:
9193
return getX86_64TargetInfo();
9294
}

lld/ELF/Target.h

+1
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ TargetInfo *getPPC64TargetInfo();
186186
TargetInfo *getPPCTargetInfo();
187187
TargetInfo *getRISCVTargetInfo();
188188
TargetInfo *getSPARCV9TargetInfo();
189+
TargetInfo *getSystemZTargetInfo();
189190
TargetInfo *getX86TargetInfo();
190191
TargetInfo *getX86_64TargetInfo();
191192
template <class ELFT> TargetInfo *getMipsTargetInfo();

lld/test/ELF/Inputs/systemz-init.s

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// glibc < 2.39 used to align .init and .fini code at a 4-byte boundary.
2+
// This file aims to recreate that behavior.
3+
.section .init,"ax",@progbits
4+
.align 4
5+
lg %r4, 272(%r15)

lld/test/ELF/basic-systemz.s

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# REQUIRES: systemz
2+
# RUN: llvm-mc -filetype=obj -triple=s390x-unknown-linux %s -o %t.o
3+
# RUN: ld.lld --hash-style=sysv -discard-all -shared %t.o -o %t.so
4+
# RUN: llvm-readelf --file-header --program-headers --section-headers --dynamic-table %t.so | FileCheck %s
5+
6+
# Exits with return code 55 on linux.
7+
.text
8+
lghi 2,55
9+
svc 1
10+
11+
// CHECK: ELF Header:
12+
// CHECK-NEXT: Magic: 7f 45 4c 46 02 02 01 00 00 00 00 00 00 00 00 00
13+
// CHECK-NEXT: Class: ELF64
14+
// CHECK-NEXT: Data: 2's complement, big endian
15+
// CHECK-NEXT: Version: 1 (current)
16+
// CHECK-NEXT: OS/ABI: UNIX - System V
17+
// CHECK-NEXT: ABI Version: 0
18+
// CHECK-NEXT: Type: DYN (Shared object file)
19+
// CHECK-NEXT: Machine: IBM S/390
20+
// CHECK-NEXT: Version: 0x1
21+
// CHECK-NEXT: Entry point address: 0x0
22+
// CHECK-NEXT: Start of program headers: 64 (bytes into file)
23+
// CHECK-NEXT: Start of section headers: 768 (bytes into file)
24+
// CHECK-NEXT: Flags: 0x0
25+
// CHECK-NEXT: Size of this header: 64 (bytes)
26+
// CHECK-NEXT: Size of program headers: 56 (bytes)
27+
// CHECK-NEXT: Number of program headers: 7
28+
// CHECK-NEXT: Size of section headers: 64 (bytes)
29+
// CHECK-NEXT: Number of section headers: 11
30+
// CHECK-NEXT: Section header string table index: 9
31+
32+
// CHECK: Section Headers:
33+
// CHECK-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
34+
// CHECK-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0 0
35+
// CHECK-NEXT: [ 1] .dynsym DYNSYM 00000000000001c8 0001c8 000018 18 A 3 1 8
36+
// CHECK-NEXT: [ 2] .hash HASH 00000000000001e0 0001e0 000010 04 A 1 0 4
37+
// CHECK-NEXT: [ 3] .dynstr STRTAB 00000000000001f0 0001f0 000001 00 A 0 0 1
38+
// CHECK-NEXT: [ 4] .text PROGBITS 00000000000011f4 0001f4 000006 00 AX 0 0 4
39+
// CHECK-NEXT: [ 5] .dynamic DYNAMIC 0000000000002200 000200 000060 10 WA 3 0 8
40+
// CHECK-NEXT: [ 6] .relro_padding NOBITS 0000000000002260 000260 000da0 00 WA 0 0 1
41+
// CHECK-NEXT: [ 7] .comment PROGBITS 0000000000000000 000260 000008 01 MS 0 0 1
42+
// CHECK-NEXT: [ 8] .symtab SYMTAB 0000000000000000 000268 000030 18 10 2 8
43+
// CHECK-NEXT: [ 9] .shstrtab STRTAB 0000000000000000 000298 000058 00 0 0 1
44+
// CHECK-NEXT: [10] .strtab STRTAB 0000000000000000 0002f0 00000a 00 0 0 1
45+
46+
// CHECK: Program Headers:
47+
// CHECK-NEXT: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
48+
// CHECK-NEXT: PHDR 0x000040 0x0000000000000040 0x0000000000000040 0x000188 0x000188 R 0x8
49+
// CHECK-NEXT: LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x0001f1 0x0001f1 R 0x1000
50+
// CHECK-NEXT: LOAD 0x0001f4 0x00000000000011f4 0x00000000000011f4 0x000006 0x000006 R E 0x1000
51+
// CHECK-NEXT: LOAD 0x000200 0x0000000000002200 0x0000000000002200 0x000060 0x000e00 RW 0x1000
52+
// CHECK-NEXT: DYNAMIC 0x000200 0x0000000000002200 0x0000000000002200 0x000060 0x000060 RW 0x8
53+
// CHECK-NEXT: GNU_RELRO 0x000200 0x0000000000002200 0x0000000000002200 0x000060 0x000e00 R 0x1
54+
// CHECK-NEXT: GNU_STACK 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000 RW 0x0
55+
56+
// CHECK: Dynamic section at offset 0x200 contains 6 entries:
57+
// CHECK-NEXT: Tag Type Name/Value
58+
// CHECK-NEXT: 0x0000000000000006 (SYMTAB) 0x1c8
59+
// CHECK-NEXT: 0x000000000000000b (SYMENT) 24 (bytes)
60+
// CHECK-NEXT: 0x0000000000000005 (STRTAB) 0x1f0
61+
// CHECK-NEXT: 0x000000000000000a (STRSZ) 1 (bytes)
62+
// CHECK-NEXT: 0x0000000000000004 (HASH) 0x1e0
63+
// CHECK-NEXT: 0x0000000000000000 (NULL) 0x0

lld/test/ELF/emulation-systemz.s

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# REQUIRES: systemz
2+
# RUN: llvm-mc -filetype=obj -triple=s390x-unknown-linux %s -o %t
3+
# RUN: ld.lld -m elf64_s390 %t -o %t2
4+
# RUN: llvm-readelf --file-header %t2 | FileCheck %s
5+
# RUN: ld.lld %t -o %t3
6+
# RUN: llvm-readelf --file-header %t3 | FileCheck %s
7+
# RUN: echo 'OUTPUT_FORMAT(elf64-s390)' > %t.script
8+
# RUN: ld.lld %t.script %t -o %t4
9+
# RUN: llvm-readelf --file-header %t4 | FileCheck %s
10+
11+
// CHECK: ELF Header:
12+
// CHECK-NEXT: Magic: 7f 45 4c 46 02 02 01 00 00 00 00 00 00 00 00 00
13+
// CHECK-NEXT: Class: ELF64
14+
// CHECK-NEXT: Data: 2's complement, big endian
15+
// CHECK-NEXT: Version: 1 (current)
16+
// CHECK-NEXT: OS/ABI: UNIX - System V
17+
// CHECK-NEXT: ABI Version: 0
18+
// CHECK-NEXT: Type: EXEC (Executable file)
19+
// CHECK-NEXT: Machine: IBM S/390
20+
// CHECK-NEXT: Version: 0x1
21+
// CHECK-NEXT: Entry point address:
22+
// CHECK-NEXT: Start of program headers: 64 (bytes into file)
23+
// CHECK-NEXT: Start of section headers:
24+
// CHECK-NEXT: Flags: 0x0
25+
// CHECK-NEXT: Size of this header: 64 (bytes)
26+
// CHECK-NEXT: Size of program headers: 56 (bytes)
27+
28+
.globl _start
29+
_start:

lld/test/ELF/lto/systemz.ll

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
; REQUIRES: systemz
2+
;; Test we can infer the e_machine value EM_S390 from a bitcode file.
3+
4+
; RUN: llvm-as %s -o %t.o
5+
; RUN: ld.lld %t.o -o %t
6+
; RUN: llvm-readobj -h %t | FileCheck %s
7+
8+
; CHECK: Class: 64-bit
9+
; CHECK: DataEncoding: BigEndian
10+
; CHECK: Machine: EM_S390
11+
12+
target datalayout = "E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64"
13+
target triple = "s390x-unknown-linux-gnu"
14+
15+
define void @_start() {
16+
entry:
17+
ret void
18+
}

lld/test/ELF/systemz-gnu-ifunc.s

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// REQUIRES: systemz
2+
// RUN: llvm-mc -filetype=obj -triple=s390x-none-linux-gnu %s -o %t.o
3+
// RUN: ld.lld -static %t.o -o %tout
4+
// RUN: llvm-objdump --no-print-imm-hex -d --no-show-raw-insn %tout | FileCheck %s --check-prefix=DISASM
5+
// RUN: llvm-readelf --section-headers --relocations --symbols %tout | FileCheck %s
6+
7+
// CHECK: There are 9 section headers
8+
// CHECK: Section Headers:
9+
// CHECK-NEXT: [Nr] Name Type Address Off Size ES Flg Lk Inf Al
10+
// CHECK-NEXT: [ 0] NULL 0000000000000000 000000 000000 00 0 0 0
11+
// CHECK-NEXT: [ 1] .rela.dyn RELA 0000000001000158 000158 000030 18 AI 0 4 8
12+
// CHECK-NEXT: [ 2] .text PROGBITS 0000000001001188 000188 00001c 00 AX 0 0 4
13+
// CHECK-NEXT: [ 3] .iplt PROGBITS 00000000010011b0 0001b0 000040 00 AX 0 0 16
14+
// CHECK-NEXT: [ 4] .got.plt PROGBITS 00000000010021f0 0001f0 000010 00 WA 0 0 8
15+
// CHECK-NEXT: [ 5] .comment PROGBITS 0000000000000000 000200 000008 01 MS 0 0 1
16+
// CHECK-NEXT: [ 6] .symtab SYMTAB 0000000000000000 000208 000090 18 8 3 8
17+
// CHECK-NEXT: [ 7] .shstrtab STRTAB 0000000000000000 000298 000043 00 0 0 1
18+
// CHECK-NEXT: [ 8] .strtab STRTAB 0000000000000000 0002db 000032 00 0 0 1
19+
20+
// CHECK: Relocation section '.rela.dyn' at offset 0x158 contains 2 entries:
21+
// CHECK-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
22+
// CHECK-NEXT: 00000000010021f0 000000000000003d R_390_IRELATIVE 1001188
23+
// CHECK-NEXT: 00000000010021f8 000000000000003d R_390_IRELATIVE 100118a
24+
25+
// CHECK: Symbol table '.symtab' contains 6 entries:
26+
// CHECK-NEXT: Num: Value Size Type Bind Vis Ndx Name
27+
// CHECK-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
28+
// CHECK-NEXT: 1: 0000000001000158 0 NOTYPE LOCAL HIDDEN 1 __rela_iplt_start
29+
// CHECK-NEXT: 2: 0000000001000188 0 NOTYPE LOCAL HIDDEN 1 __rela_iplt_end
30+
// CHECK-NEXT: 3: 0000000001001188 0 IFUNC GLOBAL DEFAULT 2 foo
31+
// CHECK-NEXT: 4: 000000000100118a 0 IFUNC GLOBAL DEFAULT 2 bar
32+
// CHECK-NEXT: 5: 000000000100118c 0 NOTYPE GLOBAL DEFAULT 2 _start
33+
34+
// DISASM: Disassembly of section .text:
35+
// DISASM-EMPTY:
36+
// DISASM-NEXT: <foo>:
37+
// DISASM-NEXT: 1001188: br %r14
38+
// DISASM: <bar>:
39+
// DISASM-NEXT: 100118a: br %r14
40+
// DISASM: <_start>:
41+
// DISASM-NEXT: 100118c: brasl %r14, 0x10011b0
42+
// DISASM-NEXT: 1001192: brasl %r14, 0x10011d0
43+
// DISASM-NEXT: 1001198: larl %r2, 0x1000158
44+
// DISASM-NEXT: 100119e: larl %r2, 0x1000188
45+
// DISASM-EMPTY:
46+
// DISASM-NEXT: Disassembly of section .iplt:
47+
// DISASM-EMPTY:
48+
// DISASM-NEXT: <.iplt>:
49+
// DISASM: 10011b0: larl %r1, 0x10021f0
50+
// DISASM-NEXT: 10011b6: lg %r1, 0(%r1)
51+
// DISASM-NEXT: 10011bc: br %r1
52+
// DISASM: 10011d0: larl %r1, 0x10021f8
53+
// DISASM-NEXT: 10011d6: lg %r1, 0(%r1)
54+
// DISASM-NEXT: 10011dc: br %r1
55+
56+
.text
57+
.type foo STT_GNU_IFUNC
58+
.globl foo
59+
foo:
60+
br %r14
61+
62+
.type bar STT_GNU_IFUNC
63+
.globl bar
64+
bar:
65+
br %r14
66+
67+
.globl _start
68+
_start:
69+
brasl %r14, foo@plt
70+
brasl %r14, bar@plt
71+
larl %r2, __rela_iplt_start
72+
larl %r2, __rela_iplt_end

lld/test/ELF/systemz-got.s

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// REQUIRES: systemz
2+
// RUN: llvm-mc -filetype=obj -triple=s390x-unknown-linux %s -o %t.o
3+
// RUN: llvm-mc -filetype=obj -triple=s390x-unknown-linux %p/Inputs/shared.s -o %t2.o
4+
// RUN: ld.lld -shared %t2.o -soname=%t2.so -o %t2.so
5+
6+
// RUN: ld.lld -dynamic-linker /lib/ld64.so.1 %t.o %t2.so -o %t
7+
// RUN: llvm-readelf -S -r %t | FileCheck %s
8+
9+
// CHECK: .got PROGBITS {{.*}} {{.*}} 000020 00 WA 0 0 8
10+
11+
// CHECK: Relocation section '.rela.dyn' at offset {{.*}} contains 1 entries:
12+
// CHECK: {{.*}} 000000010000000a R_390_GLOB_DAT 0000000000000000 bar + 0
13+
14+
.global _start
15+
_start:
16+
lgrl %r1,bar@GOT

0 commit comments

Comments
 (0)