bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Multiple setting of a symbol


From: Schwarz, Konrad
Subject: RE: Multiple setting of a symbol
Date: Mon, 11 Sep 2006 18:12:22 +0200

> From: Nick Clifton [mailto:address@hidden 

> > Specifically, given the code
> > 
> > my_variable:
> >     .long X
> >     X = 1
> >     X = 2
> > 
> > the new version assembles the value 1 into my_variable, 
> while the old 
> > version assembles the value 2.
> 
> The problem with this is what should happen in more complex 
> situations. 
>   For example:
> 
>       .long X
>       X = 1
>       X = 2
>       .long X
>       X = 3
> 
> Now, should that first .long receive the value 2, as you 
> suggested in your example, or 3, as that is the last value 
> assigned to X ?  Also what value should be given to the 
> second .long ?  2, which was the value of X at the point in 
> the code when it was defined, or 3 ?

Setting the second definition to 2 and the first to 3 would be fine by
me.  The rule would be "use current values of symbols if assigned,
otherwise treat as an undefined reference".  Furthermore, it would be
quite natural to restrict use of an undefined reference to those
relocations that are allowed by the linker (e.g., "symbol + offset" with
"offset" fixed, i.e., known when processing the reference during the
"first pass").

It just seems much more useful when referencing an undefined symbol to
obtain the final rather than the initial value, and in fact, I think
this is what the old assembler did.

>    .text
>    .long X
>    X = 1
>    .data
>    X = 2
>    .long X
>    .section "foo"
>    X = 3
> 
> Does this make any difference to the values stored in the .long's ?

I do not see why it should.  X is an absolute symbol and therefore
resides in the absolute section, the fact that it is defined while other
sections are "current" is irrelevant.

In any case, the behavior should be clearly documented.

Regards,

Konrad Schwarz




reply via email to

[Prev in Thread] Current Thread [Next in Thread]