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