MIPS/GAS: Fix null pointer dereferences in R6 PC-relative relocation checks
authorMaciej W. Rozycki <macro@imgtec.com>
Tue, 21 Jun 2016 19:12:00 +0000 (20:12 +0100)
committerMaciej W. Rozycki <macro@imgtec.com>
Tue, 21 Jun 2016 22:00:01 +0000 (23:00 +0100)
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'.

gas/ChangeLog
gas/config/tc-mips.c

index 45a505434e74d0f9ea82737917df836ccc8ab514..6ccbaa24145575dced7b62d3f17afa37dd8e21b3 100644 (file)
@@ -1,3 +1,9 @@
+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>:
index 74f7e00560768e0fa23adc8baeb1f9de9c48eead..c598806b8f381d7a2f7ce4efa8cb84e5e63fa252 100644 (file)
@@ -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;
This page took 0.035708 seconds and 4 git commands to generate.