1# REQUIRES: systemz 2## Test R_390_GOTENT optimization. 3 4# RUN: llvm-mc -filetype=obj -triple=s390x-unknown-linux %s -o %t.o 5# RUN: ld.lld %t.o -o %t1 --no-apply-dynamic-relocs 6# RUN: llvm-readelf -S -r -x .got.plt %t1 | FileCheck --check-prefixes=CHECK,NOAPPLY %s 7# RUN: ld.lld %t.o -o %t1 --apply-dynamic-relocs 8# RUN: llvm-readelf -S -r -x .got.plt %t1 | FileCheck --check-prefixes=CHECK,APPLY %s 9# RUN: ld.lld %t.o -o %t1 10# RUN: llvm-objdump --no-print-imm-hex -d %t1 | FileCheck --check-prefix=DISASM %s 11 12## --no-relax disables GOT optimization. 13# RUN: ld.lld --no-relax %t.o -o %t2 14# RUN: llvm-objdump --no-print-imm-hex -d %t2 | FileCheck --check-prefix=NORELAX %s 15 16## In our implementation, .got is retained even if all GOT-generating relocations are optimized. 17# CHECK: Name Type Address Off Size ES Flg Lk Inf Al 18# CHECK: .iplt PROGBITS 0000000001001240 000240 000020 00 AX 0 0 16 19# CHECK-NEXT: .got PROGBITS 0000000001002260 000260 000018 00 WA 0 0 8 20# CHECK-NEXT: .relro_padding NOBITS 0000000001002278 000278 000d88 00 WA 0 0 1 21# CHECK-NEXT: .got.plt PROGBITS 0000000001003278 000278 000008 00 WA 0 0 8 22 23## There is one R_S390_IRELATIVE relocation. 24# CHECK-LABEL: Relocation section '.rela.dyn' at offset {{.*}} contains 1 entries: 25# CHECK: 0000000001003278 000000000000003d R_390_IRELATIVE 10011e8 26 27# CHECK-LABEL: Hex dump of section '.got.plt': 28# NOAPPLY-NEXT: 0x01003278 00000000 00000000 29# APPLY-NEXT: 0x01003278 00000000 010011e8 30 31# DISASM: Disassembly of section .text: 32# DISASM: 00000000010011e0 <foo>: 33# DISASM-NEXT: nop 34# DISASM: 00000000010011e4 <hid>: 35# DISASM-NEXT: nop 36# DISASM: 00000000010011e8 <ifunc>: 37# DISASM-NEXT: br %r14 38# DISASM: 00000000010011ea <_start>: 39# DISASM-NEXT: larl %r1, 0x10011e0 40# DISASM-NEXT: larl %r1, 0x10011e0 41# DISASM-NEXT: larl %r1, 0x10011e4 42# DISASM-NEXT: larl %r1, 0x10011e4 43# DISASM-NEXT: lgrl %r1, 0x1003278 44# DISASM-NEXT: lgrl %r1, 0x1003278 45# DISASM-NEXT: larl %r1, 0x10011e0 46# DISASM-NEXT: larl %r1, 0x10011e0 47# DISASM-NEXT: larl %r1, 0x10011e4 48# DISASM-NEXT: larl %r1, 0x10011e4 49# DISASM-NEXT: lgrl %r1, 0x1003278 50# DISASM-NEXT: lgrl %r1, 0x1003278 51 52# NORELAX-LABEL: <_start>: 53# NORELAX-COUNT-12: lgrl 54 55.text 56.globl foo 57 58.text 59.globl foo 60.type foo, @function 61foo: 62 nop 63 64.globl hid 65.hidden hid 66.type hid, @function 67hid: 68 nop 69 70.text 71.type ifunc STT_GNU_IFUNC 72.globl ifunc 73.type ifunc, @function 74ifunc: 75 br %r14 76 77.globl _start 78.type _start, @function 79_start: 80 lgrl %r1, foo@GOT 81 lgrl %r1, foo@GOT 82 lgrl %r1, hid@GOT 83 lgrl %r1, hid@GOT 84 lgrl %r1, ifunc@GOT 85 lgrl %r1, ifunc@GOT 86 lgrl %r1, foo@GOT 87 lgrl %r1, foo@GOT 88 lgrl %r1, hid@GOT 89 lgrl %r1, hid@GOT 90 lgrl %r1, ifunc@GOT 91 lgrl %r1, ifunc@GOT 92