[ELF] Make SyntheticSection parameter order match InputSection
[llvm-project.git] / lld / test / ELF / mips-got-and-copy.s
blobc401db812026d014c518fd27fe64f5db94998a63
1 # REQUIRES: mips
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
6 # and GOT entry.
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
19 # CHECK-NEXT: }
20 # CHECK-NEXT: ]
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: -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
37 # CHECK-NEXT: }
38 # CHECK-NEXT: Entry {
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
46 # CHECK-NEXT: }
47 # CHECK-NEXT: ]
48 # CHECK-NEXT: Number of TLS and multi-GOT entries: 0
49 # CHECK-NEXT: }
51 .text
52 .global __start
53 __start:
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)