This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Initialize the X_md field


On Wed, Apr 21, 2010 at 6:28 PM, Alan Modra <amodra@gmail.com> wrote:
> On Wed, Apr 21, 2010 at 10:10:01AM -0700, H.J. Lu wrote:
>> Index: expr.c
>> ===================================================================
>> RCS file: /cvs/src/src/gas/expr.c,v
>> retrieving revision 1.81
>> diff -u -p -r1.81 expr.c
>> --- expr.c ? ?11 Dec 2009 13:42:09 -0000 ? ? ?1.81
>> +++ expr.c ? ?21 Apr 2010 16:56:34 -0000
>> @@ -1740,6 +1740,7 @@ expr (int rankarg, ? ? ? ? ? ? ?/* Larger # is highe
>>
>> ? ? ? ?input_line_pointer += op_chars; ? ? ? ?/* -> after operator. ?*/
>>
>> + ? ? ?right.X_md = 0;
>> ? ? ? ?rightseg = expr (op_rank[(int) op_left], &right, mode);
>> ? ? ? ?if (right.X_op == O_absent)
>> ? ? ? {
>
> There are many other calls to expr(). ?Why is it that just this one
> needs to init X_md?
>

"right" is allocated on the stack in expr, which is uninitialized in
recursive call. Later it does:

resultP->X_op_symbol = make_expr_symbol (&right);

which calls

symbol_set_value_expression (symbolP, expressionP);

which does

s->sy_value = *exp;

That is how the uninitialized value leaked out from expr. Other
calls to expr are different.


-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]