3 # If there are two relocations such that the first one requires
4 # dynamic COPY relocation, the second one requires GOT entry
5 # creation, linker should create both - dynamic relocation
8 # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \
9 # RUN: %S/Inputs/mips-dynamic.s -o %t.so.o
10 # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o
11 # RUN: ld.lld %t.so.o -shared -o %t.so
12 # RUN: ld.lld %t.o %t.so -o %t.exe
13 # RUN: llvm-readobj -r -A %t.exe | FileCheck %s
15 # CHECK: Relocations [
16 # CHECK-NEXT: Section (7) .rel.dyn {
17 # CHECK-NEXT: 0x[[DATA0:[0-9A-F]+]] R_MIPS_COPY data0
18 # CHECK-NEXT: 0x[[DATA1:[0-9A-F]+]] R_MIPS_COPY data1
22 # CHECK: Primary GOT {
23 # CHECK-NEXT: Canonical gp value:
24 # CHECK-NEXT: Reserved entries [
26 # CHECK-NEXT: Local entries [
28 # CHECK-NEXT: Global entries [
30 # CHECK-NEXT: Address:
31 # CHECK-NEXT: Access: -32744
32 # CHECK-NEXT: Initial: 0x[[DATA0]]
33 # CHECK-NEXT: Value: 0x[[DATA0]]
34 # CHECK-NEXT: Type: Object
35 # CHECK-NEXT: Section: .bss
36 # CHECK-NEXT: Name: data0
39 # CHECK-NEXT: Address:
40 # CHECK-NEXT: Access: -32740
41 # CHECK-NEXT: Initial: 0x[[DATA1]]
42 # CHECK-NEXT: Value: 0x[[DATA1]]
43 # CHECK-NEXT: Type: Object
44 # CHECK-NEXT: Section: .bss
45 # CHECK-NEXT: Name: data1
48 # CHECK-NEXT: Number of TLS and multi-GOT entries: 0
54 # Case A: 'got' relocation goes before 'copy' relocation
55 lui $t0
,%hi
(data0
) # R_MIPS_HI16 - requires R_MISP_COPY relocation
56 addi $t0
,$t0
,%lo
(data0
)
57 lw $t0
,%got
(data0
)($gp
) # R_MIPS_GOT16 - requires GOT entry
59 # Case B: 'copy' relocation goes before 'got' relocation
60 lw $t0
,%got
(data1
)($gp
) # R_MIPS_GOT16 - requires GOT entry
61 lui $t0
,%hi
(data1
) # R_MIPS_HI16 - requires R_MISP_COPY relocation
62 addi $t0
,$t0
,%lo
(data1
)