summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@imgtec.com>2016-06-21 20:12:00 +0100
committerMaciej W. Rozycki <macro@imgtec.com>2016-06-21 23:00:01 +0100
commit717ba204e06d88ed68441e236da3688a92cf054c (patch)
tree6bfeb73efc1891684acba3d24cf8e33726e0e596
parent51f6035b9ec8b4a23d73bed6688804e5f595e1c2 (diff)
downloadbinutils-gdb-717ba204e06d88ed68441e236da3688a92cf054c.tar.gz
MIPS/GAS: Fix null pointer dereferences in R6 PC-relative relocation checks
Avoid segmentation faults in alignment checks made in `md_apply_fix' for BFD_RELOC_MIPS_18_PCREL_S3 and BFD_RELOC_MIPS_19_PCREL_S2 relocations caused by dereferencing `fixP->fx_addsy' which will be null if the relocation processed has been fully resolved. gas/ * config/tc-mips.c (md_apply_fix) <BFD_RELOC_MIPS_18_PCREL_S3> <BFD_RELOC_MIPS_19_PCREL_S2>: Avoid null pointer dereferences via `fixP->fx_addsy'.
-rw-r--r--gas/ChangeLog6
-rw-r--r--gas/config/tc-mips.c4
2 files changed, 8 insertions, 2 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 45a505434e7..6ccbaa24145 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,5 +1,11 @@
2016-06-21 Maciej W. Rozycki <macro@imgtec.com>
+ * config/tc-mips.c (md_apply_fix) <BFD_RELOC_MIPS_18_PCREL_S3>
+ <BFD_RELOC_MIPS_19_PCREL_S2>: Avoid null pointer dereferences
+ via `fixP->fx_addsy'.
+
+2016-06-21 Maciej W. Rozycki <macro@imgtec.com>
+
* config/tc-mips.c (md_pcrel_from) <BFD_RELOC_MIPS_18_PCREL_S3>:
Calculate relocation from the containing aligned doubleword.
(tc_gen_reloc) <BFD_RELOC_MIPS_18_PCREL_S3>: Calculate the
diff --git a/gas/config/tc-mips.c b/gas/config/tc-mips.c
index 74f7e005607..c598806b8f3 100644
--- a/gas/config/tc-mips.c
+++ b/gas/config/tc-mips.c
@@ -15034,7 +15034,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
break;
case BFD_RELOC_MIPS_18_PCREL_S3:
- if ((S_GET_VALUE (fixP->fx_addsy) & 0x7) != 0)
+ if (fixP->fx_addsy && (S_GET_VALUE (fixP->fx_addsy) & 0x7) != 0)
as_bad_where (fixP->fx_file, fixP->fx_line,
_("PC-relative access using misaligned symbol (%lx)"),
(long) S_GET_VALUE (fixP->fx_addsy));
@@ -15050,7 +15050,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
if ((*valP & 0x3) != 0)
as_bad_where (fixP->fx_file, fixP->fx_line,
_("PC-relative access to misaligned address (%lx)"),
- (long) (S_GET_VALUE (fixP->fx_addsy) + fixP->fx_offset));
+ (long) *valP);
gas_assert (!fixP->fx_done);
break;