1# RUN: rm -rf %t && mkdir -p %t 2# RUN: llvm-mc -triple=mips64el-unknown-linux -target-abi n32 -filetype=obj -o %t/test_ELF_N32.o %s 3# RUN: llc -mtriple=mips64el-unknown-linux -target-abi n32 -filetype=obj -o %t/test_ELF_ExternalFunction_N32.o %S/Inputs/ExternalFunction.ll 4# RUN: llvm-rtdyld -triple=mips64el-unknown-linux -verify -map-section test_ELF_N32.o,.text=0x1000 -map-section test_ELF_ExternalFunction_N32.o,.text=0x10000 -check=%s %t/test_ELF_N32.o %t/test_ELF_ExternalFunction_N32.o 5 6# RUN: llvm-mc -triple=mips64-unknown-linux -target-abi n32 -filetype=obj -o %t/test_ELF_N32.o %s 7# RUN: llc -mtriple=mips64-unknown-linux -target-abi n32 -filetype=obj -o %t/test_ELF_ExternalFunction_N32.o %S/Inputs/ExternalFunction.ll 8# RUN: llvm-rtdyld -triple=mips64-unknown-linux -verify -map-section test_ELF_N32.o,.text=0x1000 -map-section test_ELF_ExternalFunction_N32.o,.text=0x10000 -check=%s %t/test_ELF_N32.o %t/test_ELF_ExternalFunction_N32.o 9 10 .data 11# Test R_MIPS_PC32 relocation. 12# rtdyld-check: *{4}(R_MIPS_PC32) = (foo - R_MIPS_PC32)[31:0] 13R_MIPS_PC32: 14 .word foo-. 15# rtdyld-check: *{4}(R_MIPS_PC32 + 4) = (foo - tmp1)[31:0] 16tmp1: 17 .4byte foo-tmp1 18 19 .text 20 .abicalls 21 .section .mdebug.abi64,"",@progbits 22 .nan legacy 23 .file "ELF_N32_PIC_relocations.ll" 24 .text 25 .globl bar 26 .align 3 27 .type bar,@function 28 .set nomicromips 29 .set nomips16 30 .ent bar 31bar: 32 .frame $fp,40,$ra 33 .mask 0x00000000,0 34 .fmask 0x00000000,0 35 .set noreorder 36 .set nomacro 37 .set noat 38 daddiu $sp, $sp, -40 39 sd $ra, 32($sp) 40 sd $fp, 24($sp) 41 move $fp, $sp 42 sd $4, 16($fp) 43 lb $2, 0($4) 44 sd $4, 8($fp) 45 46# Test R_MIPS_26 relocation. 47# rtdyld-check: decode_operand(insn1, 0)[27:0] = stub_addr(test_ELF_N32.o/.text, foo)[27:0] 48insn1: 49 .option pic0 50 jal foo 51 .option pic2 52 nop 53 54# Test R_MIPS_PC16 relocation. 55# rtdyld-check: decode_operand(insn2, 1)[17:0] = (foo - insn2)[17:0] 56insn2: 57 bal foo 58 nop 59 60 move $sp, $fp 61 ld $ra, 32($sp) 62 ld $fp, 24($sp) 63 daddiu $sp, $sp, 32 64 jr $ra 65 nop 66 .set at 67 .set macro 68 .set reorder 69 .end bar 70$func_end0: 71 .size bar, ($func_end0)-bar 72 73 .globl main 74 .align 3 75 .type main,@function 76 .set nomicromips 77 .set nomips16 78 .ent main 79main: 80 .frame $fp,32,$ra 81 .mask 0x00000000,0 82 .fmask 0x00000000,0 83 .set noreorder 84 .set nomacro 85 .set noat 86 daddiu $sp, $sp, -32 87 sd $ra, 24($sp) 88 sd $fp, 16($sp) 89 sd $gp, 8($sp) 90 move $fp, $sp 91 92# $gp register contains address of the .got section + 0x7FF0. 0x7FF0 is 93# the offset of $gp from the beginning of the .got section. Check that we are 94# loading address of the page pointer from correct offset. In this case 95# the page pointer is the first entry in the .got section, so offset will be 96# 0 - 0x7FF0. 97# rtdyld-check: decode_operand(insn5, 2)[15:0] = 0x8010 98# 99# Check that the global offset table contains the page pointer. 100# rtdyld-check: *{4}(section_addr(test_ELF_N32.o, .got)) = (_str + 0x8000) & 0xffff0000 101insn5: 102 ld $25, %got_page(_str)($1) 103 104# Check the offset of _str from the page pointer. 105# rtdyld-check: decode_operand(insn6, 2)[15:0] = _str[15:0] 106insn6: 107 daddiu $25, $25, %got_ofst(_str) 108 109# Check that we are loading address of var from correct offset. In this case 110# var is the second entry in the .got section, so offset will be 4 - 0x7FF0. 111# rtdyld-check: decode_operand(insn7, 2)[15:0] = 0x8014 112# 113# Check that the global offset table contains the address of the var. 114# rtdyld-check: *{4}(section_addr(test_ELF_N32.o, .got) + 4) = var 115insn7: 116 ld $2, %got_disp(var)($1) 117 sd $25, 0($2) 118 119# Check that we are loading address of bar from correct offset. In this case 120# bar is the third entry in the .got section, so offset will be 8 - 0x7FF0. 121# rtdyld-check: decode_operand(insn8, 2)[15:0] = 0x8018 122# 123# Check that the global offset table contains the address of the bar. 124# rtdyld-check: *{4}(section_addr(test_ELF_N32.o, .got) + 8) = bar 125insn8: 126 ld $2, %call16(bar)($1) 127 128 move $4, $25 129 move $gp, $1 130 move $25, $2 131 jalr $25 132 nop 133 move $sp, $fp 134 ld $gp, 8($sp) 135 ld $fp, 16($sp) 136 ld $ra, 24($sp) 137 daddiu $sp, $sp, 32 138 jr $ra 139 nop 140 .set at 141 .set macro 142 .set reorder 143 .end main 144$func_end1: 145 .size main, ($func_end1)-main 146 147 .type _str,@object 148 .section .rodata.str1.1,"aMS",@progbits,1 149_str: 150 .asciz "test" 151 .size _str, 5 152 153 .type var,@object 154 .comm var,8,8 155 156 .section ".note.GNU-stack","",@progbits 157 .text 158