1# REQUIRES: mips 2# Check MIPS multi-GOT layout. 3 4# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t0.o 5# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ 6# RUN: %p/Inputs/mips-mgot-1.s -o %t1.o 7# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ 8# RUN: %p/Inputs/mips-mgot-2.s -o %t2.o 9# RUN: echo "SECTIONS { \ 10# RUN: . = 0x10000; .text : { *(.text) } \ 11# RUN: . = 0x70000; .got : { *(.got) } \ 12# RUN: }" > %t.script 13# RUN: ld.lld -shared -mips-got-size 52 --script %t.script %t0.o %t1.o %t2.o -o %t.so 14# RUN: llvm-objdump -s --section=.got -t %t.so | FileCheck %s 15# RUN: llvm-readobj -r --dyn-syms -A %t.so | FileCheck -check-prefix=GOT %s 16 17# CHECK: SYMBOL TABLE: 18# CHECK: 00000000 l O .tdata 00000000 loc0 19# CHECK: [[FOO0:[0-9a-f]+]] g .text 00000000 foo0 20# CHECK: 00000000 g O .tdata 00000000 tls0 21# CHECK: 00000004 g O .tdata 00000000 tls1 22# CHECK: [[FOO2:[0-9a-f]+]] g .text 00000000 foo2 23 24# CHECK: Contents of section .got: 25# CHECK-NEXT: 70000 00000000 80000000 [[FOO0]] [[FOO2]] 26# CHECK-NEXT: 70010 00000000 00000004 00010000 00020000 27# CHECK-NEXT: 70020 00030000 00040000 00050000 00060000 28# CHECK-NEXT: 70030 00000000 00000000 00000000 00000000 29# CHECK-NEXT: 70040 00000000 00000000 00000000 30 31# GOT: Relocations [ 32# GOT-NEXT: Section (7) .rel.dyn { 33# GOT-NEXT: 0x70018 R_MIPS_REL32 - 0x0 34# GOT-NEXT: 0x7001C R_MIPS_REL32 - 0x0 35# GOT-NEXT: 0x70020 R_MIPS_REL32 - 0x0 36# GOT-NEXT: 0x70024 R_MIPS_REL32 - 0x0 37# GOT-NEXT: 0x70028 R_MIPS_REL32 - 0x0 38# GOT-NEXT: 0x7002C R_MIPS_REL32 - 0x0 39# GOT-NEXT: 0x70030 R_MIPS_REL32 foo0 0x0 40# GOT-NEXT: 0x70034 R_MIPS_REL32 foo2 0x0 41# GOT-NEXT: 0x70044 R_MIPS_TLS_DTPMOD32 - 0x0 42# GOT-NEXT: 0x70010 R_MIPS_TLS_TPREL32 tls0 0x0 43# GOT-NEXT: 0x70038 R_MIPS_TLS_TPREL32 tls0 0x0 44# GOT-NEXT: 0x7003C R_MIPS_TLS_DTPMOD32 tls0 0x0 45# GOT-NEXT: 0x70040 R_MIPS_TLS_DTPREL32 tls0 0x0 46# GOT-NEXT: 0x70014 R_MIPS_TLS_TPREL32 tls1 0x0 47# GOT-NEXT: } 48# GOT-NEXT: ] 49 50# GOT: DynamicSymbols [ 51# GOT: Symbol { 52# GOT: Name: foo0 53# GOT-NEXT: Value: 0x[[FOO0:[0-9A-F]+]] 54# GOT: } 55# GOT-NEXT: Symbol { 56# GOT-NEXT: Name: foo2 57# GOT-NEXT: Value: 0x[[FOO2:[0-9A-F]+]] 58# GOT: } 59# GOT-NEXT: ] 60 61# GOT: Primary GOT { 62# GOT-NEXT: Canonical gp value: 0x77FF0 63# GOT-NEXT: Reserved entries [ 64# GOT-NEXT: Entry { 65# GOT-NEXT: Address: 66# GOT-NEXT: Access: -32752 67# GOT-NEXT: Initial: 0x0 68# GOT-NEXT: Purpose: Lazy resolver 69# GOT-NEXT: } 70# GOT-NEXT: Entry { 71# GOT-NEXT: Address: 72# GOT-NEXT: Access: -32748 73# GOT-NEXT: Initial: 0x80000000 74# GOT-NEXT: Purpose: Module pointer (GNU extension) 75# GOT-NEXT: } 76# GOT-NEXT: ] 77# GOT-NEXT: Local entries [ 78# GOT-NEXT: ] 79# GOT-NEXT: Global entries [ 80# GOT-NEXT: Entry { 81# GOT-NEXT: Address: 82# GOT-NEXT: Access: -32744 83# GOT-NEXT: Initial: 0x[[FOO0]] 84# GOT-NEXT: Value: 0x[[FOO0]] 85# GOT-NEXT: Type: None 86# GOT-NEXT: Section: .text 87# GOT-NEXT: Name: foo0 88# GOT-NEXT: } 89# GOT-NEXT: Entry { 90# GOT-NEXT: Address: 91# GOT-NEXT: Access: -32740 92# GOT-NEXT: Initial: 0x[[FOO2]] 93# GOT-NEXT: Value: 0x[[FOO2]] 94# GOT-NEXT: Type: None 95# GOT-NEXT: Section: .text 96# GOT-NEXT: Name: foo2 97# GOT-NEXT: } 98# GOT-NEXT: ] 99# GOT-NEXT: Number of TLS and multi-GOT entries: 15 100# GOT-NEXT: } 101 102 .text 103 .global foo0 104foo0: 105 lw $2, %got(.data)($gp) # page entry 106 addi $2, $2, %lo(.data) 107 lw $2, %call16(foo0)($gp) # global entry 108 addiu $2, $2, %tlsgd(tls0) # tls gd entry 109 addiu $2, $2, %gottprel(tls0) # tls got entry 110 addiu $2, $2, %tlsldm(loc0) # tls ld entry 111 112 .data 113 .space 0x20000 114 115 .section .tdata,"awT",%progbits 116 .global tls0 117tls0: 118loc0: 119 .word 0 120