+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>:
 
       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));
       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;