This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: [Patch] Fix gas crash (when compiled with clang)
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: Tristan Gingold <gingold at adacore dot com>
- Cc: "binutils at sourceware dot org Development" <binutils at sourceware dot org>
- Date: Tue, 3 Dec 2013 08:22:46 -0800
- Subject: Re: [Patch] Fix gas crash (when compiled with clang)
- Authentication-results: sourceware.org; auth=none
- References: <8B3FF3BC-DF21-4B09-AAE0-52A253540772 at adacore dot com>
On Tue, Dec 3, 2013 at 8:11 AM, Tristan Gingold <gingold@adacore.com> wrote:
> Hi,
>
> when compiled with clang (llvm 3.3), gas crashes on the intelbad test.
> I suppose this is due to use of overflow on pointer arithmetic.
>
> Fixed by the following patch, no gas regression for x86_64-pc-mingw32.
>
> Ok for trunk ?
>
> Tristan.
>
> gas/
> 2013-12-03 Tristan Gingold <gingold@adacore.com>
>
> * config/tc-i386-intel.c (i386_intel_simplify): Avoid arithmetic
> overflow on pointers.
>
> diff --git a/gas/config/tc-i386-intel.c b/gas/config/tc-i386-intel.c
> index 8a2224a..6df17e2 100644
> --- a/gas/config/tc-i386-intel.c
> +++ b/gas/config/tc-i386-intel.c
> @@ -417,23 +417,21 @@ static int i386_intel_simplify (expressionS *e)
> if (this_operand >= 0 && intel_state.in_bracket)
> {
> expressionS *scale = NULL;
> -
> - if (intel_state.index)
> - --scale;
> + int has_index = (intel_state.index != NULL);
>
> if (!intel_state.in_scale++)
> intel_state.scale_factor = 1;
>
> ret = i386_intel_simplify_symbol (e->X_add_symbol);
> - if (ret && !scale && intel_state.index)
> + if (ret && !has_index && intel_state.index)
> scale = symbol_get_value_expression (e->X_op_symbol);
>
> if (ret)
> ret = i386_intel_simplify_symbol (e->X_op_symbol);
> - if (ret && !scale && intel_state.index)
> + if (ret && !scale && !has_index && intel_state.index)
> scale = symbol_get_value_expression (e->X_add_symbol);
>
> - if (ret && scale && (scale + 1))
> + if (ret && scale)
> {
> resolve_expression (scale);
> if (scale->X_op != O_constant
>
OK. Thanks.
--
H.J.