[PATCH 2/4] GAS: Make new fake labels when cloning a symbol

Richard Sandiford rdsandiford@googlemail.com
Mon Aug 30 17:53:00 GMT 2010


> @@ -645,18 +645,23 @@ symbol_clone_if_forward_ref (symbolS *sy
>  
>        /* Re-using sy_resolving here, as this routine cannot get called from
>  	 symbol resolution code.  */
> -      if (symbolP->bsym->section == expr_section && !symbolP->sy_resolving)
> +      if ((symbolP->bsym->section == expr_section
> +	   || (!is_deferred && symbolP->sy_forward_ref))
> +	  && !symbolP->sy_resolving)

Is the idea that if is_deferred is true, this function will be called
again each time symbolP is used in another (non-deferred) expression,
at which point the necessary cloning will happen?  If so, why do we need
to clone _any_ symbols in the deferred case?  I.e. for:

       .eqv     s2,s1
       .eqv     s3,s2
       .eqv     s4,s3
       ...

it seems that you're cloning:

 - s2, but not s1, for s3
 - s3, but not s2, for s4

and so on.  Couldn't we simply avoid calling symbol_clone_if_forward_ref
in the deferred case, and leave all cloning to the point of use?

The answer may well be "no". :-)  I'm just trying to understand the
reasoning.  Whatever the answer is, I think it needs a comment.

The first patch looks generally good otherwise, so hopefully any
changes are just a mopping-up exercise.  I'm still uneasy about the
second patch though.  Can you justify why the new test for "." is safe?

An alternative might be to model "." as a single forward-reference
symbol whose value is redefined before each instruction.  I think
that's what its semantics actually are.  There would then be a
single global symbol that represents ".", and that is marked as a
forward reference.  symbol_clone_if_forward_ref would return
symbol_temp_new_now for that symbol, rather than go through
the usual cloning process.

Richard



More information about the Binutils mailing list