2 # RUN: echo '.globl bar, weak; .type bar,@function; .type weak,@function; bar: weak:' > %t1.s
4 # RUN: llvm-mc -filetype=obj -triple=s390x-unknown-linux %t1.s -o %t1.o
5 # RUN: ld.lld -shared %t1.o -soname=t1.so -o %t1.so
6 # RUN: llvm-mc -filetype=obj -triple=s390x-unknown-linux %s -o %t.o
7 # RUN: ld.lld %t.o %t1.so -z separate-code -o %t
8 # RUN: llvm-readelf -S -s -r -x .got.plt %t | FileCheck %s
9 # RUN: llvm-objdump -d %t | FileCheck --check-prefixes=DIS %s
11 # CHECK: Section Headers:
12 # CHECK: .plt PROGBITS 0000000001001020 001020 000060 00 AX 0 0 16
13 # CHECK: .got PROGBITS 00000000010020d0 0020d0 000018 00 WA 0 0 8
14 # CHECK: .got.plt PROGBITS 00000000010030e8 0020e8 000010 00 WA 0 0 8
16 # CHECK: Relocation section '.rela.plt' at offset {{.*}} contains 2 entries:
17 # CHECK: 00000000010030e8 000000010000000b R_390_JMP_SLOT 0000000000000000 bar + 0
18 # CHECK: 00000000010030f0 000000020000000b R_390_JMP_SLOT 0000000000000000 weak + 0
20 ## A canonical PLT has a non-zero st_value. bar and weak are called but their
21 ## addresses are not taken, so a canonical PLT is not necessary.
22 # CHECK: Symbol table '.dynsym' contains 3 entries:
23 # CHECK-NEXT: Num: Value Size Type Bind Vis Ndx Name
24 # CHECK-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
25 # CHECK-NEXT: 1: 0000000000000000 0 FUNC GLOBAL DEFAULT UND bar
26 # CHECK-NEXT: 2: 0000000000000000 0 FUNC WEAK DEFAULT UND weak
28 ## The .got.plt slots relocated by .rela.plt point to .plt
29 ## This is required by glibc.
30 # CHECK: Hex dump of section '.got.plt':
31 # CHECK-NEXT: 0x010030e8 00000000 0100104e 00000000 0100106e
33 # DIS: Disassembly of section .text:
35 # DIS: 0000000001001000 <_start>:
36 # DIS-NEXT: brasl %r14, 0x1001012
37 # DIS-NEXT: brasl %r14, 0x1001040
38 # DIS-NEXT: brasl %r14, 0x1001060
40 # DIS: 0000000001001012 <foo>:
43 # DIS: Disassembly of section .plt:
45 # DIS: 0000000001001020 <.plt>:
46 # DIS-NEXT: 1001020: e3 10 f0 38 00 24 stg %r1, 56(%r15)
47 # DIS-NEXT: 1001026: c0 10 00 00 08 55 larl %r1, 0x10020d0
48 # DIS-NEXT: 100102c: d2 07 f0 30 10 08 mvc 48(8,%r15), 8(%r1)
49 # DIS-NEXT: 1001032: e3 10 10 10 00 04 lg %r1, 16(%r1)
50 # DIS-NEXT: 1001038: 07 f1 br %r1
51 # DIS-NEXT: 100103a: 07 00 nopr %r0
52 # DIS-NEXT: 100103c: 07 00 nopr %r0
53 # DIS-NEXT: 100103e: 07 00 nopr %r0
54 # DIS-NEXT: 1001040: c0 10 00 00 10 54 larl %r1, 0x10030e8
55 # DIS-NEXT: 1001046: e3 10 10 00 00 04 lg %r1, 0(%r1)
56 # DIS-NEXT: 100104c: 07 f1 br %r1
57 # DIS-NEXT: 100104e: 0d 10 basr %r1, 0
58 # DIS-NEXT: 1001050: e3 10 10 0c 00 14 lgf %r1, 12(%r1)
59 # DIS-NEXT: 1001056: c0 f4 ff ff ff e5 jg 0x1001020
60 # DIS-NEXT: 100105c: 00 00 <unknown>
61 # DIS-NEXT: 100105e: 00 00 <unknown>
62 # DIS-NEXT: 1001060: c0 10 00 00 10 48 larl %r1, 0x10030f0
63 # DIS-NEXT: 1001066: e3 10 10 00 00 04 lg %r1, 0(%r1)
64 # DIS-NEXT: 100106c: 07 f1 br %r1
65 # DIS-NEXT: 100106e: 0d 10 basr %r1, 0
66 # DIS-NEXT: 1001070: e3 10 10 0c 00 14 lgf %r1, 12(%r1)
67 # DIS-NEXT: 1001076: c0 f4 ff ff ff d5 jg 0x1001020
68 # DIS-NEXT: 100107c: 00 00 <unknown>
69 # DIS-NEXT: 100107e: 00 18 <unknown>
71 .global _start, foo, bar
75 ## Use @plt to avoid generating direct references that would force
76 ## allocation of a canonical PLT entry.
81 ## foo is local and non-preemptable, no PLT is generated.