This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[committed 2/3] MIPS/GAS: Fix null pointer dereferences in R6 PC-relative relocation checks
- From: "Maciej W. Rozycki" <macro at imgtec dot com>
- To: <binutils at sourceware dot org>
- Date: Tue, 21 Jun 2016 23:12:00 +0100
- Subject: [committed 2/3] MIPS/GAS: Fix null pointer dereferences in R6 PC-relative relocation checks
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 2 dot 00 dot 1606211808390 dot 7182 at tp dot orcam dot me dot uk>
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'.
---
binutils-mips-gas-r6-pcrel-reloc-segv.diff
Index: binutils/gas/config/tc-mips.c
===================================================================
--- binutils.orig/gas/config/tc-mips.c 2016-06-20 18:57:55.000000000 +0100
+++ binutils/gas/config/tc-mips.c 2016-06-20 19:01:02.478736376 +0100
@@ -15034,7 +15034,7 @@ md_apply_fix (fixS *fixP, valueT *valP,
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,
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;