mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-12-01 05:55:23 +08:00
as: fixed internal error when immediate value of relocation overflow.
The as and ld use _bfd_error_handler to output error messages when checking relocation alignment and relocation overflow. However, the abfd value passed by as to the function is NULL, resulting in an internal error. The ld passes a non-null value to the function, so it can output an error message normally.
This commit is contained in:
parent
8bf3b48f72
commit
f87cf663af
@ -1682,9 +1682,14 @@ reloc_sign_bits (bfd *abfd, reloc_howto_type *howto, bfd_vma *fix_val)
|
||||
if (howto->rightshift
|
||||
&& (val & ((((bfd_signed_vma) 1) << howto->rightshift) - 1)))
|
||||
{
|
||||
(*_bfd_error_handler) (_("%pB: relocation %s right shift %d error 0x%lx"),
|
||||
abfd, howto->name, howto->rightshift, (long) val);
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
/* The as passes NULL casued internal error, so it can not use _bfd_error_handler
|
||||
output details, ld is not affected. */
|
||||
if (abfd != NULL)
|
||||
{
|
||||
(*_bfd_error_handler) (_("%pB: relocation %s right shift %d error 0x%lx"),
|
||||
abfd, howto->name, howto->rightshift, (long) val);
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -1696,9 +1701,14 @@ reloc_sign_bits (bfd *abfd, reloc_howto_type *howto, bfd_vma *fix_val)
|
||||
high part: from sign bit to highest bit. */
|
||||
if ((val & ~mask) && ((val & ~mask) != ~mask))
|
||||
{
|
||||
(*_bfd_error_handler) (_("%pB: relocation %s overflow 0x%lx"),
|
||||
abfd, howto->name, (long) val);
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
/* The as passes NULL casued internal error, so it can not use _bfd_error_handler
|
||||
output details, ld is not affected. */
|
||||
if (abfd != NULL)
|
||||
{
|
||||
(*_bfd_error_handler) (_("%pB: relocation %s overflow 0x%lx"),
|
||||
abfd, howto->name, (long) val);
|
||||
bfd_set_error (bfd_error_bad_value);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1234,7 +1234,7 @@ static void fix_reloc_insn (fixS *fixP, bfd_vma reloc_val, char *buf)
|
||||
insn = bfd_getl32 (buf);
|
||||
|
||||
if (!loongarch_adjust_reloc_bitsfield (NULL, howto, &reloc_val))
|
||||
as_warn_where (fixP->fx_file, fixP->fx_line, "Reloc overflow");
|
||||
as_bad_where (fixP->fx_file, fixP->fx_line, "Reloc overflow");
|
||||
|
||||
insn = (insn & (insn_t)howto->src_mask)
|
||||
| ((insn & (~(insn_t)howto->dst_mask)) | reloc_val);
|
||||
|
3
gas/testsuite/gas/loongarch/imm_overflow.d
Normal file
3
gas/testsuite/gas/loongarch/imm_overflow.d
Normal file
@ -0,0 +1,3 @@
|
||||
#as:
|
||||
#source: imm_overflow.s
|
||||
#error_output: imm_overflow.l
|
2
gas/testsuite/gas/loongarch/imm_overflow.l
Normal file
2
gas/testsuite/gas/loongarch/imm_overflow.l
Normal file
@ -0,0 +1,2 @@
|
||||
.*Assembler messages:
|
||||
.*Error: Reloc overflow
|
4
gas/testsuite/gas/loongarch/imm_overflow.s
Normal file
4
gas/testsuite/gas/loongarch/imm_overflow.s
Normal file
@ -0,0 +1,4 @@
|
||||
.L1:
|
||||
nop
|
||||
.fill 0x3ffffff, 4, 0
|
||||
b .L1
|
3
gas/testsuite/gas/loongarch/imm_unalign.d
Normal file
3
gas/testsuite/gas/loongarch/imm_unalign.d
Normal file
@ -0,0 +1,3 @@
|
||||
#as:
|
||||
#source: imm_unalign.s
|
||||
#error_output: imm_unalign.l
|
2
gas/testsuite/gas/loongarch/imm_unalign.l
Normal file
2
gas/testsuite/gas/loongarch/imm_unalign.l
Normal file
@ -0,0 +1,2 @@
|
||||
.*Assembler messages:
|
||||
.*Error: Reloc overflow
|
6
gas/testsuite/gas/loongarch/imm_unalign.s
Normal file
6
gas/testsuite/gas/loongarch/imm_unalign.s
Normal file
@ -0,0 +1,6 @@
|
||||
.L1:
|
||||
.2byte 0x12
|
||||
|
||||
.L2:
|
||||
.fill 1, 4, 0
|
||||
b .L1
|
Loading…
Reference in New Issue
Block a user