* elf32-mips.c (mips_elf_calculate_relocation): Fix overflow handling
of R_MIPS_PC16. * config/tc-mips.c (append_insn): Handle BFD_RELOC_16_PCREL. (macro_build): Use BFD_RELOC_16_PCREL_S2 only for embedded PIC, BFD_RELOC_16_PCREL for the rest. (mips_ip): Likewise. (md_pcrel_from): return the right offset for the differently shifted pcrel relocs. (md_apply_fix): Handle BFD_RELOC_16_PCREL. * gas/mips/beq.d: Check branches to external labels. * gas/mips/beq.s: Likewise. * gas/mips/bge.d: Likewise. * gas/mips/bge.s: Likewise. * gas/mips/bgeu.d: Likewise. * gas/mips/bgeu.s: Likewise. * gas/mips/blt.d: Likewise. * gas/mips/blt.s: Likewise. * gas/mips/bltu.d: Likewise. * gas/mips/bltu.s: Likewise. * gas/mips/elempic.d: Switch from R_MIPS_GNU_REL16_S2 to R_MIPS_PC16. * gas/mips/empic.d: Likewise. * gas/mips/empic.s: Likewise. * gas/mips/telempic.d: Likewise. * gas/mips/tempic.d: Likewise.
This commit is contained in:
parent
c0a1a2e89b
commit
cb56d3d327
@ -1,3 +1,8 @@
|
|||||||
|
2001-09-07 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
|
||||||
|
|
||||||
|
* elf32-mips.c (mips_elf_calculate_relocation): Fix overflow handling
|
||||||
|
of R_MIPS_PC16.
|
||||||
|
|
||||||
2001-09-06 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
|
2001-09-06 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
|
||||||
|
|
||||||
* elf64-mips.c (mips_elf64_howto_table_rel): Fix relocation HOWTO
|
* elf64-mips.c (mips_elf64_howto_table_rel): Fix relocation HOWTO
|
||||||
|
@ -6480,8 +6480,8 @@ mips_elf_calculate_relocation (abfd,
|
|||||||
|
|
||||||
case R_MIPS_PC16:
|
case R_MIPS_PC16:
|
||||||
value = mips_elf_sign_extend (addend, 16) + symbol - p;
|
value = mips_elf_sign_extend (addend, 16) + symbol - p;
|
||||||
value = (bfd_vma) ((bfd_signed_vma) value / 4);
|
|
||||||
overflowed_p = mips_elf_overflow_p (value, 16);
|
overflowed_p = mips_elf_overflow_p (value, 16);
|
||||||
|
value = (bfd_vma) ((bfd_signed_vma) value / 4);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R_MIPS_GOT_HI16:
|
case R_MIPS_GOT_HI16:
|
||||||
|
@ -1,3 +1,13 @@
|
|||||||
|
2001-09-07 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
|
||||||
|
|
||||||
|
* config/tc-mips.c (append_insn): Handle BFD_RELOC_16_PCREL.
|
||||||
|
(macro_build): Use BFD_RELOC_16_PCREL_S2 only for embedded
|
||||||
|
PIC, BFD_RELOC_16_PCREL for the rest.
|
||||||
|
(mips_ip): Likewise.
|
||||||
|
(md_pcrel_from): return the right offset for the differently shifted
|
||||||
|
pcrel relocs.
|
||||||
|
(md_apply_fix): Handle BFD_RELOC_16_PCREL.
|
||||||
|
|
||||||
2001-09-05 Richard Henderson <rth@redhat.com>
|
2001-09-05 Richard Henderson <rth@redhat.com>
|
||||||
|
|
||||||
* config/tc-ia64.c (FUNC_IPLT_RELOC): New.
|
* config/tc-ia64.c (FUNC_IPLT_RELOC): New.
|
||||||
|
@ -1898,6 +1898,10 @@ append_insn (place, ip, address_expr, reloc_type, unmatched_hi)
|
|||||||
| ((address_expr->X_add_number & 0x3fffc) >> 2));
|
| ((address_expr->X_add_number & 0x3fffc) >> 2));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case BFD_RELOC_16_PCREL:
|
||||||
|
ip->insn_opcode |= (address_expr->X_add_number >> 2) & 0xffff;
|
||||||
|
break;
|
||||||
|
|
||||||
case BFD_RELOC_16_PCREL_S2:
|
case BFD_RELOC_16_PCREL_S2:
|
||||||
goto need_reloc;
|
goto need_reloc;
|
||||||
|
|
||||||
@ -1914,7 +1918,8 @@ append_insn (place, ip, address_expr, reloc_type, unmatched_hi)
|
|||||||
{
|
{
|
||||||
fixp = fix_new_exp (frag_now, f - frag_now->fr_literal, 4,
|
fixp = fix_new_exp (frag_now, f - frag_now->fr_literal, 4,
|
||||||
address_expr,
|
address_expr,
|
||||||
reloc_type == BFD_RELOC_16_PCREL_S2,
|
(reloc_type == BFD_RELOC_16_PCREL
|
||||||
|
|| reloc_type == BFD_RELOC_16_PCREL_S2),
|
||||||
reloc_type);
|
reloc_type);
|
||||||
if (unmatched_hi)
|
if (unmatched_hi)
|
||||||
{
|
{
|
||||||
@ -2699,7 +2704,10 @@ macro_build (place, counter, ep, name, fmt, va_alist)
|
|||||||
ep = NULL;
|
ep = NULL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
if (mips_pic == EMBEDDED_PIC)
|
||||||
r = BFD_RELOC_16_PCREL_S2;
|
r = BFD_RELOC_16_PCREL_S2;
|
||||||
|
else
|
||||||
|
r = BFD_RELOC_16_PCREL;
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'a':
|
case 'a':
|
||||||
@ -7796,7 +7804,10 @@ mips_ip (str, ip)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'p': /* pc relative offset */
|
case 'p': /* pc relative offset */
|
||||||
|
if (mips_pic == EMBEDDED_PIC)
|
||||||
offset_reloc = BFD_RELOC_16_PCREL_S2;
|
offset_reloc = BFD_RELOC_16_PCREL_S2;
|
||||||
|
else
|
||||||
|
offset_reloc = BFD_RELOC_16_PCREL;
|
||||||
my_getExpression (&offset_expr, s);
|
my_getExpression (&offset_expr, s);
|
||||||
s = expr_end;
|
s = expr_end;
|
||||||
continue;
|
continue;
|
||||||
@ -9425,11 +9436,18 @@ md_pcrel_from (fixP)
|
|||||||
if (OUTPUT_FLAVOR != bfd_target_aout_flavour
|
if (OUTPUT_FLAVOR != bfd_target_aout_flavour
|
||||||
&& fixP->fx_addsy != (symbolS *) NULL
|
&& fixP->fx_addsy != (symbolS *) NULL
|
||||||
&& ! S_IS_DEFINED (fixP->fx_addsy))
|
&& ! S_IS_DEFINED (fixP->fx_addsy))
|
||||||
|
{
|
||||||
|
if (mips_pic == EMBEDDED_PIC)
|
||||||
{
|
{
|
||||||
/* This makes a branch to an undefined symbol be a branch to the
|
/* This makes a branch to an undefined symbol be a branch to the
|
||||||
current location. */
|
current location. */
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* return the address of the delay slot */
|
/* return the address of the delay slot */
|
||||||
return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address;
|
return fixP->fx_size + fixP->fx_where + fixP->fx_frag->fr_address;
|
||||||
@ -9665,7 +9683,8 @@ md_apply_fix (fixP, valueP)
|
|||||||
/* BFD's REL handling, for MIPS, is _very_ weird.
|
/* BFD's REL handling, for MIPS, is _very_ weird.
|
||||||
This gives the right results, but it can't possibly
|
This gives the right results, but it can't possibly
|
||||||
be the way things are supposed to work. */
|
be the way things are supposed to work. */
|
||||||
if (fixP->fx_r_type != BFD_RELOC_16_PCREL_S2
|
if ((fixP->fx_r_type != BFD_RELOC_16_PCREL
|
||||||
|
&& fixP->fx_r_type != BFD_RELOC_16_PCREL_S2)
|
||||||
|| S_GET_SEGMENT (fixP->fx_addsy) != undefined_section)
|
|| S_GET_SEGMENT (fixP->fx_addsy) != undefined_section)
|
||||||
value += fixP->fx_frag->fr_address + fixP->fx_where;
|
value += fixP->fx_frag->fr_address + fixP->fx_where;
|
||||||
}
|
}
|
||||||
@ -9811,15 +9830,18 @@ md_apply_fix (fixP, valueP)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case BFD_RELOC_16_PCREL_S2:
|
case BFD_RELOC_16_PCREL_S2:
|
||||||
|
if ((value & 0x3) != 0)
|
||||||
|
as_bad_where (fixP->fx_file, fixP->fx_line,
|
||||||
|
_("Branch to odd address (%lx)"), (long) value);
|
||||||
|
|
||||||
|
/* Fall through. */
|
||||||
|
|
||||||
|
case BFD_RELOC_16_PCREL:
|
||||||
/*
|
/*
|
||||||
* We need to save the bits in the instruction since fixup_segment()
|
* We need to save the bits in the instruction since fixup_segment()
|
||||||
* might be deleting the relocation entry (i.e., a branch within
|
* might be deleting the relocation entry (i.e., a branch within
|
||||||
* the current segment).
|
* the current segment).
|
||||||
*/
|
*/
|
||||||
if ((value & 0x3) != 0)
|
|
||||||
as_bad_where (fixP->fx_file, fixP->fx_line,
|
|
||||||
_("Branch to odd address (%lx)"), (long) value);
|
|
||||||
|
|
||||||
if (!fixP->fx_done && value != 0)
|
if (!fixP->fx_done && value != 0)
|
||||||
break;
|
break;
|
||||||
/* If 'value' is zero, the remaining reloc code won't actually
|
/* If 'value' is zero, the remaining reloc code won't actually
|
||||||
|
@ -1,3 +1,21 @@
|
|||||||
|
2001-09-07 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
|
||||||
|
|
||||||
|
* gas/mips/beq.d: Check branches to external labels.
|
||||||
|
* gas/mips/beq.s: Likewise.
|
||||||
|
* gas/mips/bge.d: Likewise.
|
||||||
|
* gas/mips/bge.s: Likewise.
|
||||||
|
* gas/mips/bgeu.d: Likewise.
|
||||||
|
* gas/mips/bgeu.s: Likewise.
|
||||||
|
* gas/mips/blt.d: Likewise.
|
||||||
|
* gas/mips/blt.s: Likewise.
|
||||||
|
* gas/mips/bltu.d: Likewise.
|
||||||
|
* gas/mips/bltu.s: Likewise.
|
||||||
|
* gas/mips/elempic.d: Switch from R_MIPS_GNU_REL16_S2 to R_MIPS_PC16.
|
||||||
|
* gas/mips/empic.d: Likewise.
|
||||||
|
* gas/mips/empic.s: Likewise.
|
||||||
|
* gas/mips/telempic.d: Likewise.
|
||||||
|
* gas/mips/tempic.d: Likewise.
|
||||||
|
|
||||||
2001-09-06 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
|
2001-09-06 Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
|
||||||
|
|
||||||
* gas/mips/tmips16-f.d: New file, testcase for big endian MIPS16
|
* gas/mips/tmips16-f.d: New file, testcase for big endian MIPS16
|
||||||
|
@ -37,4 +37,10 @@ Disassembly of section .text:
|
|||||||
0+2006c <[^>]*> nop
|
0+2006c <[^>]*> nop
|
||||||
0+20070 <[^>]*> jal 0+0000 <text_label>
|
0+20070 <[^>]*> jal 0+0000 <text_label>
|
||||||
[ ]*20070: (MIPS_JMP|JMPADDR|R_MIPS_26) .text
|
[ ]*20070: (MIPS_JMP|JMPADDR|R_MIPS_26) .text
|
||||||
|
0+20074 <[^>]*> nop
|
||||||
|
0+20078 <[^>]*> b 0+20078 <text_label\+0x20078>
|
||||||
|
[ ]*20078: R_MIPS_PC16 external_label
|
||||||
|
0+2007c <[^>]*> nop
|
||||||
|
0+20080 <[^>]*> bal 0+20080 <text_label\+0x20080>
|
||||||
|
[ ]*20080: R_MIPS_PC16 external_label
|
||||||
...
|
...
|
||||||
|
@ -22,7 +22,9 @@ text_label:
|
|||||||
b text_label
|
b text_label
|
||||||
bal text_label
|
bal text_label
|
||||||
|
|
||||||
|
# Branch to an external label.
|
||||||
|
b external_label
|
||||||
|
bal external_label
|
||||||
|
|
||||||
# Round to a 16 byte boundary, for ease in testing multiple targets.
|
# Round to a 16 byte boundary, for ease in testing multiple targets.
|
||||||
nop
|
nop
|
||||||
nop
|
|
||||||
nop
|
|
||||||
|
@ -50,4 +50,20 @@ Disassembly of section .text:
|
|||||||
0+00a4 <[^>]*> nop
|
0+00a4 <[^>]*> nop
|
||||||
0+00a8 <[^>]*> slt at,a1,a0
|
0+00a8 <[^>]*> slt at,a1,a0
|
||||||
0+00ac <[^>]*> bnezl at,0+0000 <text_label>
|
0+00ac <[^>]*> bnezl at,0+0000 <text_label>
|
||||||
|
0+00b0 <[^>]*> nop
|
||||||
|
0+00b4 <[^>]*> slt at,a0,a1
|
||||||
|
0+00b8 <[^>]*> beqz at,000000b8 <text_label\+0xb8>
|
||||||
|
[ ]*b8: R_MIPS_PC16 external_label
|
||||||
|
0+00bc <[^>]*> nop
|
||||||
|
0+00c0 <[^>]*> slt at,a1,a0
|
||||||
|
0+00c4 <[^>]*> bnez at,000000c4 <text_label\+0xc4>
|
||||||
|
[ ]*c4: R_MIPS_PC16 external_label
|
||||||
|
0+00c8 <[^>]*> nop
|
||||||
|
0+00cc <[^>]*> slt at,a0,a1
|
||||||
|
0+00d0 <[^>]*> beqzl at,000000d0 <text_label\+0xd0>
|
||||||
|
[ ]*d0: R_MIPS_PC16 external_label
|
||||||
|
0+00d4 <[^>]*> nop
|
||||||
|
0+00d8 <[^>]*> slt at,a1,a0
|
||||||
|
0+00dc <[^>]*> bnezl at,000000dc <text_label\+0xdc>
|
||||||
|
[ ]*dc: R_MIPS_PC16 external_label
|
||||||
...
|
...
|
||||||
|
@ -24,6 +24,12 @@ text_label:
|
|||||||
bgel $4,$5,text_label
|
bgel $4,$5,text_label
|
||||||
bgtl $4,$5,text_label
|
bgtl $4,$5,text_label
|
||||||
|
|
||||||
|
# Branch to an external label.
|
||||||
|
bge $4,$5,external_label
|
||||||
|
bgt $4,$5,external_label
|
||||||
|
bgel $4,$5,external_label
|
||||||
|
bgtl $4,$5,external_label
|
||||||
|
|
||||||
# Round to a 16 byte boundary, for ease in testing multiple targets.
|
# Round to a 16 byte boundary, for ease in testing multiple targets.
|
||||||
nop
|
nop
|
||||||
nop
|
nop
|
||||||
|
@ -44,4 +44,20 @@ Disassembly of section .text:
|
|||||||
0+008c <[^>]*> nop
|
0+008c <[^>]*> nop
|
||||||
0+0090 <[^>]*> sltu at,a1,a0
|
0+0090 <[^>]*> sltu at,a1,a0
|
||||||
0+0094 <[^>]*> bnezl at,0+0000 <text_label>
|
0+0094 <[^>]*> bnezl at,0+0000 <text_label>
|
||||||
|
0+0098 <[^>]*> nop
|
||||||
|
0+009c <[^>]*> sltu at,a0,a1
|
||||||
|
0+00a0 <[^>]*> beqz at,000000a0 <text_label\+0xa0>
|
||||||
|
[ ]*a0: R_MIPS_PC16 external_label
|
||||||
|
0+00a4 <[^>]*> nop
|
||||||
|
0+00a8 <[^>]*> sltu at,a1,a0
|
||||||
|
0+00ac <[^>]*> bnez at,000000ac <text_label\+0xac>
|
||||||
|
[ ]*ac: R_MIPS_PC16 external_label
|
||||||
|
0+00b0 <[^>]*> nop
|
||||||
|
0+00b4 <[^>]*> sltu at,a0,a1
|
||||||
|
0+00b8 <[^>]*> beqzl at,000000b8 <text_label\+0xb8>
|
||||||
|
[ ]*b8: R_MIPS_PC16 external_label
|
||||||
|
0+00bc <[^>]*> nop
|
||||||
|
0+00c0 <[^>]*> sltu at,a1,a0
|
||||||
|
0+00c4 <[^>]*> bnezl at,000000c4 <text_label\+0xc4>
|
||||||
|
[ ]*c4: R_MIPS_PC16 external_label
|
||||||
...
|
...
|
||||||
|
@ -22,6 +22,12 @@ text_label:
|
|||||||
bgeul $4,$5,text_label
|
bgeul $4,$5,text_label
|
||||||
bgtul $4,$5,text_label
|
bgtul $4,$5,text_label
|
||||||
|
|
||||||
|
# Branch to an external label.
|
||||||
|
bgeu $4,$5,external_label
|
||||||
|
bgtu $4,$5,external_label
|
||||||
|
bgeul $4,$5,external_label
|
||||||
|
bgtul $4,$5,external_label
|
||||||
|
|
||||||
# Round to a 16 byte boundary, for ease in testing multiple targets.
|
# Round to a 16 byte boundary, for ease in testing multiple targets.
|
||||||
nop
|
nop
|
||||||
nop
|
nop
|
||||||
|
@ -50,4 +50,20 @@ Disassembly of section .text:
|
|||||||
0+00a4 <[^>]*> nop
|
0+00a4 <[^>]*> nop
|
||||||
0+00a8 <[^>]*> slt at,a1,a0
|
0+00a8 <[^>]*> slt at,a1,a0
|
||||||
0+00ac <[^>]*> beqzl at,0+0000 <text_label>
|
0+00ac <[^>]*> beqzl at,0+0000 <text_label>
|
||||||
|
0+00b0 <[^>]*> nop
|
||||||
|
0+00b4 <[^>]*> slt at,a0,a1
|
||||||
|
0+00b8 <[^>]*> bnez at,000000b8 <text_label\+0xb8>
|
||||||
|
[ ]*b8: R_MIPS_PC16 external_label
|
||||||
|
0+00bc <[^>]*> nop
|
||||||
|
0+00c0 <[^>]*> slt at,a1,a0
|
||||||
|
0+00c4 <[^>]*> beqz at,000000c4 <text_label\+0xc4>
|
||||||
|
[ ]*c4: R_MIPS_PC16 external_label
|
||||||
|
0+00c8 <[^>]*> nop
|
||||||
|
0+00cc <[^>]*> slt at,a0,a1
|
||||||
|
0+00d0 <[^>]*> bnezl at,000000d0 <text_label\+0xd0>
|
||||||
|
[ ]*d0: R_MIPS_PC16 external_label
|
||||||
|
0+00d4 <[^>]*> nop
|
||||||
|
0+00d8 <[^>]*> slt at,a1,a0
|
||||||
|
0+00dc <[^>]*> beqzl at,000000dc <text_label\+0xdc>
|
||||||
|
[ ]*dc: R_MIPS_PC16 external_label
|
||||||
...
|
...
|
||||||
|
@ -24,6 +24,12 @@ text_label:
|
|||||||
bltl $4,$5,text_label
|
bltl $4,$5,text_label
|
||||||
blel $4,$5,text_label
|
blel $4,$5,text_label
|
||||||
|
|
||||||
|
# Branch to an external label.
|
||||||
|
blt $4,$5,external_label
|
||||||
|
ble $4,$5,external_label
|
||||||
|
bltl $4,$5,external_label
|
||||||
|
blel $4,$5,external_label
|
||||||
|
|
||||||
# Round to a 16 byte boundary, for ease in testing multiple targets.
|
# Round to a 16 byte boundary, for ease in testing multiple targets.
|
||||||
nop
|
nop
|
||||||
nop
|
nop
|
||||||
|
@ -44,4 +44,20 @@ Disassembly of section .text:
|
|||||||
0+008c <[^>]*> nop
|
0+008c <[^>]*> nop
|
||||||
0+0090 <[^>]*> sltu at,a1,a0
|
0+0090 <[^>]*> sltu at,a1,a0
|
||||||
0+0094 <[^>]*> beqzl at,0+0000 <text_label>
|
0+0094 <[^>]*> beqzl at,0+0000 <text_label>
|
||||||
|
0+0098 <[^>]*> nop
|
||||||
|
0+009c <[^>]*> sltu at,a0,a1
|
||||||
|
0+00a0 <[^>]*> bnez at,000000a0 <text_label\+0xa0>
|
||||||
|
[ ]*a0: R_MIPS_PC16 external_label
|
||||||
|
0+00a4 <[^>]*> nop
|
||||||
|
0+00a8 <[^>]*> sltu at,a1,a0
|
||||||
|
0+00ac <[^>]*> beqz at,000000ac <text_label\+0xac>
|
||||||
|
[ ]*ac: R_MIPS_PC16 external_label
|
||||||
|
0+00b0 <[^>]*> nop
|
||||||
|
0+00b4 <[^>]*> sltu at,a0,a1
|
||||||
|
0+00b8 <[^>]*> bnezl at,000000b8 <text_label\+0xb8>
|
||||||
|
[ ]*b8: R_MIPS_PC16 external_label
|
||||||
|
0+00bc <[^>]*> nop
|
||||||
|
0+00c0 <[^>]*> sltu at,a1,a0
|
||||||
|
0+00c4 <[^>]*> beqzl at,000000c4 <text_label\+0xc4>
|
||||||
|
[ ]*c4: R_MIPS_PC16 external_label
|
||||||
...
|
...
|
||||||
|
@ -22,6 +22,12 @@ text_label:
|
|||||||
bltul $4,$5,text_label
|
bltul $4,$5,text_label
|
||||||
bleul $4,$5,text_label
|
bleul $4,$5,text_label
|
||||||
|
|
||||||
|
# Branch to an external label.
|
||||||
|
bltu $4,$5,external_label
|
||||||
|
bleu $4,$5,external_label
|
||||||
|
bltul $4,$5,external_label
|
||||||
|
bleul $4,$5,external_label
|
||||||
|
|
||||||
# Round to a 16 byte boundary, for ease in testing multiple targets.
|
# Round to a 16 byte boundary, for ease in testing multiple targets.
|
||||||
nop
|
nop
|
||||||
nop
|
nop
|
||||||
|
Loading…
Reference in New Issue
Block a user