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: Relative expressions and ASSERT


Alan Modra <amodra@gmail.com> writes:

> On Wed, Jan 19, 2011 at 06:48:51AM +0000, Maciej W. Rozycki wrote:
>>  Is that intended behaviour?  From your update to the manual I infer 
>> otherwise and it looks to me like a mishandled case that slipped through, 
>> but perhaps I'm missing something.  Either way I find it plain wrong that 
>> a difference of two symbols (both coming from/relative to the same 
>> section) yields a plain number in GAS, but not in an LD script.  Hmm...
>
> ld actually does follow the current ld.texinfo description.  The two
> symbols are in the same section, so the operation (subtraction in this
> case) is performed on their offsets, yielding a result in the same
> section.
>
> Admittedly, this does lead to an odd result.  Should we special case
> subtraction?  Exclusive or too?

The last time I worked through these issues I came up with the code in
expr() in gas/expr.c.  It makes subtraction of two symbols in the same
section be absolute, whereas of course subtracting a constant gives a
result in the same section.

Ian


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