1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00
llvm-mirror/test/MC/Mips/elf-relsym.s
Dimitry Andric b9df55d1d3 Reland "[MC][ELF] Work around R_MIPS_LO16 relocation handling problem"
This fixes PR49821, and avoids "ld.lld: error: test.o:(.rodata.str1.1):
offset is outside the section" errors when linking MIPS objects with
negative R_MIPS_LO16 implicit addends.

ld.lld handles R_MIPS_HI16/R_MIPS_LO16 separately, not as a whole, so it
doesn't know that an R_MIPS_HI16 with implicit addend 1 and an
R_MIPS_LO16 with implicit addend -32768 represents 32768, which is in
range of a MergeInputSection. We could introduce a new RelExpr member
(like R_RISCV_PC_INDIRECT for R_RISCV_PCREL_HI20 / R_RISCV_PCREL_LO12)
but the complexity is unnecessary given that GNU as keeps the original
symbol for this case as well.

Adds a new test case for PR49821, and also updates two other test cases
that are affected by this change.

Reviewed By: atanasyan, MaskRay

Differential Revision: https://reviews.llvm.org/D101773
2021-05-04 18:16:09 +02:00

88 lines
1.8 KiB
ArmAsm

// RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux %s -o - | llvm-readobj --symbols - | FileCheck %s
// Check that the appropriate symbols were created.
// CHECK: Symbols [
// CHECK: Symbol {
// CHECK: Name: $CPI0_0
// CHECK: }
// CHECK: Symbol {
// CHECK: Name: $CPI0_1
// CHECK: }
// CHECK: Symbol {
// CHECK: Name: $.str
// CHECK: }
// CHECK: Symbol {
// CHECK: Name: $.str1
// CHECK: }
// CHECK: ]
.text
.abicalls
.section .mdebug.abi32,"",@progbits
.file "/home/espindola/llvm/llvm/test/MC/Mips/elf-relsym.ll"
.section .rodata.cst8,"aM",@progbits,8
.align 3
$CPI0_0:
.8byte 4612811918334230528 # double 2.5
$CPI0_1:
.8byte 4616752568008179712 # double 4.5
.text
.globl foo1
.align 2
.type foo1,@function
.set nomips16
.ent foo1
foo1: # @foo1
.frame $sp,0,$ra
.mask 0x00000000,0
.fmask 0x00000000,0
.set noreorder
.set nomacro
.set noat
# %bb.0: # %entry
lui $2, %hi(_gp_disp)
addiu $2, $2, %lo(_gp_disp)
addu $1, $2, $25
lw $2, %got($.str)($1)
addiu $2, $2, %lo($.str)
lw $3, %got(gc1)($1)
sw $2, 0($3)
lw $2, %got($.str1)($1)
addiu $2, $2, %lo($.str1)
lw $3, %got(gc2)($1)
sw $2, 0($3)
lw $2, %got($CPI0_0)($1)
ldc1 $f0, %lo($CPI0_0)($2)
lw $2, %got(gd1)($1)
ldc1 $f2, 0($2)
lw $3, %got($CPI0_1)($1)
ldc1 $f4, %lo($CPI0_1)($3)
lw $1, %got(gd2)($1)
add.d $f0, $f2, $f0
sdc1 $f0, 0($2)
ldc1 $f0, 0($1)
add.d $f0, $f0, $f4
jr $ra
sdc1 $f0, 0($1)
.set at
.set macro
.set reorder
.end foo1
$tmp0:
.size foo1, ($tmp0)-foo1
.type $.str,@object # @.str
.section .rodata.str1.1,"aMS",@progbits,1
$.str:
.asciz "abcde"
.size $.str, 6
.type $.str1,@object # @.str1
$.str1:
.asciz "fghi"
.size $.str1, 5
.text