MIPS/GAS: Don't convert RELA JALR relocations on R6

Revert an inadvertent change to make RELA JALR relocations
section-relative on MIPS R6 targets made with commit 7361da2c95 ("Add
support for MIPS R6.").  There is no need to make this a special case
and the comment introduced with the said change clearly indicates this
was not intended.

	gas/
	* config/tc-mips.c (mips_fix_adjustable): Don't convert RELA
	JALR relocations on R6.
	* testsuite/gas/mips/jal-svr4pic-local.d: New test.
	* testsuite/gas/mips/mips1@jal-svr4pic-local.d: New test.
	* testsuite/gas/mips/r3000@jal-svr4pic-local.d: New test.
	* testsuite/gas/mips/micromips@jal-svr4pic-local.d: New test.
	* testsuite/gas/mips/jal-svr4pic-local-n32.d: New test.
	* testsuite/gas/mips/micromips@jal-svr4pic-local-n32.d: New
	test.
	* testsuite/gas/mips/jal-svr4pic-local-n64.d: New test.
	* testsuite/gas/mips/micromips@jal-svr4pic-local-n64.d: New
	test.
	* testsuite/gas/mips/jal-svr4pic-local.s: New test source.
	* testsuite/gas/mips/jal-svr4pic-local-newabi.s: New test
	source.
	* testsuite/gas/mips/mips.exp: Run the new tests.
This commit is contained in:
Maciej W. Rozycki 2016-06-13 16:52:42 +01:00
parent 0c9663cbd4
commit 97f5015122
13 changed files with 342 additions and 5 deletions

View File

@ -1,3 +1,22 @@
2016-06-13 Maciej W. Rozycki <macro@imgtec.com>
* config/tc-mips.c (mips_fix_adjustable): Don't convert RELA
JALR relocations on R6.
* testsuite/gas/mips/jal-svr4pic-local.d: New test.
* testsuite/gas/mips/mips1@jal-svr4pic-local.d: New test.
* testsuite/gas/mips/r3000@jal-svr4pic-local.d: New test.
* testsuite/gas/mips/micromips@jal-svr4pic-local.d: New test.
* testsuite/gas/mips/jal-svr4pic-local-n32.d: New test.
* testsuite/gas/mips/micromips@jal-svr4pic-local-n32.d: New
test.
* testsuite/gas/mips/jal-svr4pic-local-n64.d: New test.
* testsuite/gas/mips/micromips@jal-svr4pic-local-n64.d: New
test.
* testsuite/gas/mips/jal-svr4pic-local.s: New test source.
* testsuite/gas/mips/jal-svr4pic-local-newabi.s: New test
source.
* testsuite/gas/mips/mips.exp: Run the new tests.
2016-06-13 Virendra Pathak <virendra.pathak@broadcom.com>
* config/tc-aarch64.c (aarch64_cpus): Add Broadcom Vulcan.

View File

@ -17126,16 +17126,18 @@ mips_fix_adjustable (fixS *fixp)
&& (S_GET_SEGMENT (fixp->fx_addsy)->flags & SEC_MERGE) != 0)
return 0;
/* There is no place to store an in-place offset for JALR relocations.
Likewise an in-range offset of limited PC-relative relocations may
/* There is no place to store an in-place offset for JALR relocations. */
if (jalr_reloc_p (fixp->fx_r_type) && HAVE_IN_PLACE_ADDENDS)
return 0;
/* Likewise an in-range offset of limited PC-relative relocations may
overflow the in-place relocatable field if recalculated against the
start address of the symbol's containing section.
Also, PC relative relocations for MIPS R6 need to be symbol rather than
section relative to allow linker relaxations to be performed later on. */
if ((HAVE_IN_PLACE_ADDENDS || ISA_IS_R6 (mips_opts.isa))
&& (limited_pcrel_reloc_p (fixp->fx_r_type)
|| jalr_reloc_p (fixp->fx_r_type)))
if (limited_pcrel_reloc_p (fixp->fx_r_type)
&& (HAVE_IN_PLACE_ADDENDS || ISA_IS_R6 (mips_opts.isa)))
return 0;
/* R_MIPS16_26 relocations against non-MIPS16 functions might resolve

View File

@ -0,0 +1,33 @@
#objdump: -dr --prefix-addresses --show-raw-insn
#name: MIPS JALR relocation against local symbol (n32)
#as: -n32
#source: jal-svr4pic-local-newabi.s
.*: +file format .*mips.*
Disassembly of section \.text:
[0-9a-f]+ <[^>]*> 27bdfff0 addiu sp,sp,-16
[0-9a-f]+ <[^>]*> ffbc0000 sd gp,0\(sp\)
[0-9a-f]+ <[^>]*> 3c1c0000 lui gp,0x0
[ ]*[0-9a-f]+: R_MIPS_GPREL16 foo
[ ]*[0-9a-f]+: R_MIPS_SUB \*ABS\*
[ ]*[0-9a-f]+: R_MIPS_HI16 \*ABS\*
[0-9a-f]+ <[^>]*> 279c0000 addiu gp,gp,0
[ ]*[0-9a-f]+: R_MIPS_GPREL16 foo
[ ]*[0-9a-f]+: R_MIPS_SUB \*ABS\*
[ ]*[0-9a-f]+: R_MIPS_LO16 \*ABS\*
[0-9a-f]+ <[^>]*> 0399e021 addu gp,gp,t9
[0-9a-f]+ <[^>]*> ffbf0008 sd ra,8\(sp\)
[0-9a-f]+ <[^>]*> 8f990000 lw t9,0\(gp\)
[ ]*[0-9a-f]+: R_MIPS_GOT_DISP \.text\+0x40
[0-9a-f]+ <[^>]*> 0320f809 jalr t9
[ ]*[0-9a-f]+: R_MIPS_JALR \.text\+0x40
[0-9a-f]+ <[^>]*> 00000000 nop
[0-9a-f]+ <[^>]*> dfbf0008 ld ra,8\(sp\)
[0-9a-f]+ <[^>]*> dfbc0000 ld gp,0\(sp\)
[0-9a-f]+ <[^>]*> 03e0000[89] jr ra
[0-9a-f]+ <[^>]*> 27bd0010 addiu sp,sp,16
\.\.\.
[0-9a-f]+ <[^>]*> 03e0000[89] jr ra
[0-9a-f]+ <[^>]*> 00000000 nop
\.\.\.

View File

@ -0,0 +1,37 @@
#objdump: -dr --prefix-addresses --show-raw-insn
#name: MIPS JALR relocation against local symbol (n64)
#as: -64
#source: jal-svr4pic-local-newabi.s
.*: +file format .*mips.*
Disassembly of section \.text:
[0-9a-f]+ <[^>]*> 27bdfff0 addiu sp,sp,-16
[0-9a-f]+ <[^>]*> ffbc0000 sd gp,0\(sp\)
[0-9a-f]+ <[^>]*> 3c1c0000 lui gp,0x0
[ ]*[0-9a-f]+: R_MIPS_GPREL16 foo
[ ]*[0-9a-f]+: R_MIPS_SUB \*ABS\*
[ ]*[0-9a-f]+: R_MIPS_HI16 \*ABS\*
[0-9a-f]+ <[^>]*> 279c0000 addiu gp,gp,0
[ ]*[0-9a-f]+: R_MIPS_GPREL16 foo
[ ]*[0-9a-f]+: R_MIPS_SUB \*ABS\*
[ ]*[0-9a-f]+: R_MIPS_LO16 \*ABS\*
[0-9a-f]+ <[^>]*> 0399e02d daddu gp,gp,t9
[0-9a-f]+ <[^>]*> ffbf0008 sd ra,8\(sp\)
[0-9a-f]+ <[^>]*> df990000 ld t9,0\(gp\)
[ ]*[0-9a-f]+: R_MIPS_GOT_DISP \.text\+0x40
[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x40
[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x40
[0-9a-f]+ <[^>]*> 0320f809 jalr t9
[ ]*[0-9a-f]+: R_MIPS_JALR \.text\+0x40
[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x40
[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x40
[0-9a-f]+ <[^>]*> 00000000 nop
[0-9a-f]+ <[^>]*> dfbf0008 ld ra,8\(sp\)
[0-9a-f]+ <[^>]*> dfbc0000 ld gp,0\(sp\)
[0-9a-f]+ <[^>]*> 03e0000[89] jr ra
[0-9a-f]+ <[^>]*> 27bd0010 addiu sp,sp,16
\.\.\.
[0-9a-f]+ <[^>]*> 03e0000[89] jr ra
[0-9a-f]+ <[^>]*> 00000000 nop
\.\.\.

View File

@ -0,0 +1,32 @@
.abicalls
.text
.align 4, 0
.globl foo
.ent foo
foo:
.frame $sp, 16, $31
.mask 0x90000000, -8
.fmask 0x00000000, 0
addiu $sp,$sp,-16
.cpsetup $25, 0, foo
sd $31, 8($sp)
jal bar
ld $31,8($sp)
.cpreturn
addiu $sp,$sp,16
jr $31
.end foo
.align 4, 0
.ent bar
bar:
.frame $sp, 0, $31
.mask 0x00000000, 0
.fmask 0x00000000, 0
jr $31
.end bar
# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
.align 4, 0
.space 16

View File

@ -0,0 +1,31 @@
#objdump: -dr --prefix-addresses --show-raw-insn
#name: MIPS JALR relocation against local symbol
#as: -32
#not-target: *-*-irix*
.*: +file format .*mips.*
Disassembly of section \.text:
[0-9a-f]+ <[^>]*> 3c1c0000 lui gp,0x0
[ ]*[0-9a-f]+: R_MIPS_HI16 _gp_disp
[0-9a-f]+ <[^>]*> 279c0000 addiu gp,gp,0
[ ]*[0-9a-f]+: R_MIPS_LO16 _gp_disp
[0-9a-f]+ <[^>]*> 0399e021 addu gp,gp,t9
[0-9a-f]+ <[^>]*> 27bdffe0 addiu sp,sp,-32
[0-9a-f]+ <[^>]*> afbf001c sw ra,28\(sp\)
[0-9a-f]+ <[^>]*> afbc0010 sw gp,16\(sp\)
[0-9a-f]+ <[^>]*> 8f990000 lw t9,0\(gp\)
[ ]*[0-9a-f]+: R_MIPS_GOT16 \.text
[0-9a-f]+ <[^>]*> 27390040 addiu t9,t9,64
[ ]*[0-9a-f]+: R_MIPS_LO16 \.text
[0-9a-f]+ <[^>]*> 0320f809 jalr t9
[ ]*[0-9a-f]+: R_MIPS_JALR bar
[0-9a-f]+ <[^>]*> 00000000 nop
[0-9a-f]+ <[^>]*> 8fbc0010 lw gp,16\(sp\)
[0-9a-f]+ <[^>]*> 8fbf001c lw ra,28\(sp\)
[0-9a-f]+ <[^>]*> 03e0000[89] jr ra
[0-9a-f]+ <[^>]*> 27bd0020 addiu sp,sp,32
\.\.\.
[0-9a-f]+ <[^>]*> 03e0000[89] jr ra
[0-9a-f]+ <[^>]*> 00000000 nop
\.\.\.

View File

@ -0,0 +1,34 @@
.abicalls
.text
.align 4, 0
.globl foo
.ent foo
foo:
.frame $sp, 32, $31
.mask 0x80000000, -4
.fmask 0x00000000, 0
.set noreorder
.cpload $25
.set reorder
addiu $sp, $sp, -32
sw $31, 28($sp)
.cprestore 16
jal bar
lw $31, 28($sp)
addiu $sp, $sp, 32
jr $31
.end foo
.align 4, 0
.ent bar
bar:
.frame $sp, 0, $31
.mask 0x00000000, 0
.fmask 0x00000000, 0
jr $31
.end bar
# Force some (non-delay-slot) zero bytes, to make 'objdump' print ...
.align 4, 0
.space 16

View File

@ -0,0 +1,33 @@
#objdump: -dr --prefix-addresses --show-raw-insn
#name: MIPS JALR relocation against local symbol (n32)
#as: -n32
#source: jal-svr4pic-local-newabi.s
.*: +file format .*mips.*
Disassembly of section \.text:
[0-9a-f]+ <[^>]*> 4ff9 addiu sp,sp,-16
[0-9a-f]+ <[^>]*> db9d 0000 sd gp,0\(sp\)
[0-9a-f]+ <[^>]*> 41bc 0000 lui gp,0x0
[ ]*[0-9a-f]+: R_MICROMIPS_GPREL16 foo
[ ]*[0-9a-f]+: R_MICROMIPS_SUB \*ABS\*
[ ]*[0-9a-f]+: R_MICROMIPS_HI16 \*ABS\*
[0-9a-f]+ <[^>]*> 339c 0000 addiu gp,gp,0
[ ]*[0-9a-f]+: R_MICROMIPS_GPREL16 foo
[ ]*[0-9a-f]+: R_MICROMIPS_SUB \*ABS\*
[ ]*[0-9a-f]+: R_MICROMIPS_LO16 \*ABS\*
[0-9a-f]+ <[^>]*> 033c e150 addu gp,gp,t9
[0-9a-f]+ <[^>]*> dbfd 0008 sd ra,8\(sp\)
[0-9a-f]+ <[^>]*> ff3c 0000 lw t9,0\(gp\)
[ ]*[0-9a-f]+: R_MICROMIPS_GOT_DISP \.text\+0x31
[0-9a-f]+ <[^>]*> 03f9 4f3c jalrs t9
[ ]*[0-9a-f]+: R_MICROMIPS_JALR \.text\+0x31
[0-9a-f]+ <[^>]*> 0c00 nop
[0-9a-f]+ <[^>]*> dffd 0008 ld ra,8\(sp\)
[0-9a-f]+ <[^>]*> df9d 0000 ld gp,0\(sp\)
[0-9a-f]+ <[^>]*> 459f jr ra
[0-9a-f]+ <[^>]*> 4c09 addiu sp,sp,16
[0-9a-f]+ <[^>]*> 0000 0000 nop
[0-9a-f]+ <[^>]*> 459f jr ra
[0-9a-f]+ <[^>]*> 0c00 nop
\.\.\.

View File

@ -0,0 +1,37 @@
#objdump: -dr --prefix-addresses --show-raw-insn
#name: MIPS JALR relocation against local symbol (n64)
#as: -64
#source: jal-svr4pic-local-newabi.s
.*: +file format .*mips.*
Disassembly of section \.text:
[0-9a-f]+ <[^>]*> 4ff9 addiu sp,sp,-16
[0-9a-f]+ <[^>]*> db9d 0000 sd gp,0\(sp\)
[0-9a-f]+ <[^>]*> 41bc 0000 lui gp,0x0
[ ]*[0-9a-f]+: R_MICROMIPS_GPREL16 foo
[ ]*[0-9a-f]+: R_MICROMIPS_SUB \*ABS\*
[ ]*[0-9a-f]+: R_MICROMIPS_HI16 \*ABS\*
[0-9a-f]+ <[^>]*> 339c 0000 addiu gp,gp,0
[ ]*[0-9a-f]+: R_MICROMIPS_GPREL16 foo
[ ]*[0-9a-f]+: R_MICROMIPS_SUB \*ABS\*
[ ]*[0-9a-f]+: R_MICROMIPS_LO16 \*ABS\*
[0-9a-f]+ <[^>]*> 5b3c e150 daddu gp,gp,t9
[0-9a-f]+ <[^>]*> dbfd 0008 sd ra,8\(sp\)
[0-9a-f]+ <[^>]*> df3c 0000 ld t9,0\(gp\)
[ ]*[0-9a-f]+: R_MICROMIPS_GOT_DISP \.text\+0x31
[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x31
[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x31
[0-9a-f]+ <[^>]*> 03f9 4f3c jalrs t9
[ ]*[0-9a-f]+: R_MICROMIPS_JALR \.text\+0x31
[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x31
[ ]*[0-9a-f]+: R_MIPS_NONE \*ABS\*\+0x31
[0-9a-f]+ <[^>]*> 0c00 nop
[0-9a-f]+ <[^>]*> dffd 0008 ld ra,8\(sp\)
[0-9a-f]+ <[^>]*> df9d 0000 ld gp,0\(sp\)
[0-9a-f]+ <[^>]*> 459f jr ra
[0-9a-f]+ <[^>]*> 4c09 addiu sp,sp,16
[0-9a-f]+ <[^>]*> 0000 0000 nop
[0-9a-f]+ <[^>]*> 459f jr ra
[0-9a-f]+ <[^>]*> 0c00 nop
\.\.\.

View File

@ -0,0 +1,32 @@
#objdump: -dr --prefix-addresses --show-raw-insn
#name: MIPS JALR relocation against local symbol
#as: -32
#not-target: *-*-irix*
#source: jal-svr4pic-local.s
.*: +file format .*mips.*
Disassembly of section \.text:
[0-9a-f]+ <[^>]*> 41bc 0000 lui gp,0x0
[ ]*[0-9a-f]+: R_MICROMIPS_HI16 _gp_disp
[0-9a-f]+ <[^>]*> 339c 0000 addiu gp,gp,0
[ ]*[0-9a-f]+: R_MICROMIPS_LO16 _gp_disp
[0-9a-f]+ <[^>]*> 033c e150 addu gp,gp,t9
[0-9a-f]+ <[^>]*> 4ff1 addiu sp,sp,-32
[0-9a-f]+ <[^>]*> cbe7 sw ra,28\(sp\)
[0-9a-f]+ <[^>]*> fb9d 0010 sw gp,16\(sp\)
[0-9a-f]+ <[^>]*> ff3c 0000 lw t9,0\(gp\)
[ ]*[0-9a-f]+: R_MICROMIPS_GOT16 \.text
[0-9a-f]+ <[^>]*> 3339 0031 addiu t9,t9,49
[ ]*[0-9a-f]+: R_MICROMIPS_LO16 \.text
[0-9a-f]+ <[^>]*> 03f9 4f3c jalrs t9
[ ]*[0-9a-f]+: R_MICROMIPS_JALR bar
[0-9a-f]+ <[^>]*> 0c00 nop
[0-9a-f]+ <[^>]*> ff9d 0010 lw gp,16\(sp\)
[0-9a-f]+ <[^>]*> 4be7 lw ra,28\(sp\)
[0-9a-f]+ <[^>]*> 459f jr ra
[0-9a-f]+ <[^>]*> 4c11 addiu sp,sp,32
[0-9a-f]+ <[^>]*> 0000 0000 nop
[0-9a-f]+ <[^>]*> 459f jr ra
[0-9a-f]+ <[^>]*> 0c00 nop
\.\.\.

View File

@ -655,6 +655,14 @@ if { [istarget mips*-*-vxworks*] } {
run_dump_test_arches "jal-svr4pic" [mips_arch_list_matching mips1]
run_dump_test_arches "jal-svr4pic-noreorder" \
[mips_arch_list_matching mips1]
run_dump_test_arches "jal-svr4pic-local" \
[mips_arch_list_matching mips1]
if $has_newabi {
run_dump_test_arches "jal-svr4pic-local-n32" \
[mips_arch_list_matching mips3]
run_dump_test_arches "jal-svr4pic-local-n64" \
[mips_arch_list_matching mips3]
}
run_dump_test "jal-xgot"
run_list_test_arches "jal-range" "-32" [mips_arch_list_matching mips1]
if $has_newabi { run_dump_test "jal-newabi" }

View File

@ -0,0 +1,33 @@
#objdump: -dr --prefix-addresses --show-raw-insn
#name: MIPS JALR relocation against local symbol
#as: -32
#not-target: *-*-irix*
#source: jal-svr4pic-local.s
.*: +file format .*mips.*
Disassembly of section \.text:
[0-9a-f]+ <[^>]*> 3c1c0000 lui gp,0x0
[ ]*[0-9a-f]+: R_MIPS_HI16 _gp_disp
[0-9a-f]+ <[^>]*> 279c0000 addiu gp,gp,0
[ ]*[0-9a-f]+: R_MIPS_LO16 _gp_disp
[0-9a-f]+ <[^>]*> 0399e021 addu gp,gp,t9
[0-9a-f]+ <[^>]*> 27bdffe0 addiu sp,sp,-32
[0-9a-f]+ <[^>]*> afbf001c sw ra,28\(sp\)
[0-9a-f]+ <[^>]*> afbc0010 sw gp,16\(sp\)
[0-9a-f]+ <[^>]*> 8f990000 lw t9,0\(gp\)
[ ]*[0-9a-f]+: R_MIPS_GOT16 \.text
[0-9a-f]+ <[^>]*> 00000000 nop
[0-9a-f]+ <[^>]*> 27390040 addiu t9,t9,64
[ ]*[0-9a-f]+: R_MIPS_LO16 \.text
[0-9a-f]+ <[^>]*> 0320f809 jalr t9
[ ]*[0-9a-f]+: R_MIPS_JALR bar
[0-9a-f]+ <[^>]*> 00000000 nop
[0-9a-f]+ <[^>]*> 8fbc0010 lw gp,16\(sp\)
[0-9a-f]+ <[^>]*> 8fbf001c lw ra,28\(sp\)
[0-9a-f]+ <[^>]*> 27bd0020 addiu sp,sp,32
[0-9a-f]+ <[^>]*> 03e0000[89] jr ra
[0-9a-f]+ <[^>]*> 00000000 nop
[0-9a-f]+ <[^>]*> 03e0000[89] jr ra
[0-9a-f]+ <[^>]*> 00000000 nop
\.\.\.

View File

@ -0,0 +1,6 @@
#objdump: -dr --prefix-addresses --show-raw-insn
#name: MIPS JALR relocation against local symbol
#as: -32
#not-target: *-*-irix*
#source: jal-svr4pic-local.s
#dump: mips1@jal-svr4pic-local.d