63 lines · plain
1# REQUIRES: mips2 3# If there are two relocations such that the first one requires4# dynamic COPY relocation, the second one requires GOT entry5# creation, linker should create both - dynamic relocation6# and GOT entry.7 8# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \9# RUN: %S/Inputs/mips-dynamic.s -o %t.so.o10# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o11# RUN: ld.lld %t.so.o -shared -o %t.so12# RUN: ld.lld %t.o %t.so -o %t.exe13# RUN: llvm-readobj -r -A %t.exe | FileCheck %s14 15# CHECK: Relocations [16# CHECK-NEXT: Section (7) .rel.dyn {17# CHECK-NEXT: 0x[[DATA0:[0-9A-F]+]] R_MIPS_COPY data018# CHECK-NEXT: 0x[[DATA1:[0-9A-F]+]] R_MIPS_COPY data119# CHECK-NEXT: }20# CHECK-NEXT: ]21 22# CHECK: Primary GOT {23# CHECK-NEXT: Canonical gp value:24# CHECK-NEXT: Reserved entries [25# CHECK: ]26# CHECK-NEXT: Local entries [27# CHECK-NEXT: ]28# CHECK-NEXT: Global entries [29# CHECK-NEXT: Entry {30# CHECK-NEXT: Address:31# CHECK-NEXT: Access: -3274432# CHECK-NEXT: Initial: 0x[[DATA0]]33# CHECK-NEXT: Value: 0x[[DATA0]]34# CHECK-NEXT: Type: Object35# CHECK-NEXT: Section: .bss36# CHECK-NEXT: Name: data037# CHECK-NEXT: }38# CHECK-NEXT: Entry {39# CHECK-NEXT: Address:40# CHECK-NEXT: Access: -3274041# CHECK-NEXT: Initial: 0x[[DATA1]]42# CHECK-NEXT: Value: 0x[[DATA1]]43# CHECK-NEXT: Type: Object44# CHECK-NEXT: Section: .bss45# CHECK-NEXT: Name: data146# CHECK-NEXT: }47# CHECK-NEXT: ]48# CHECK-NEXT: Number of TLS and multi-GOT entries: 049# CHECK-NEXT: }50 51 .text52 .global __start53__start:54 # Case A: 'got' relocation goes before 'copy' relocation55 lui $t0,%hi(data0) # R_MIPS_HI16 - requires R_MISP_COPY relocation56 addi $t0,$t0,%lo(data0)57 lw $t0,%got(data0)($gp) # R_MIPS_GOT16 - requires GOT entry58 59 # Case B: 'copy' relocation goes before 'got' relocation60 lw $t0,%got(data1)($gp) # R_MIPS_GOT16 - requires GOT entry61 lui $t0,%hi(data1) # R_MIPS_HI16 - requires R_MISP_COPY relocation62 addi $t0,$t0,%lo(data1)63