[Top][All Lists]

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

Re: as variable '$' have problem

From: nick clifton
Subject: Re: as variable '$' have problem
Date: Wed, 04 Sep 2013 10:43:12 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:23.0) Gecko/20100101 Firefox/23.0 SeaMonkey/2.20

Hi 研发部淡明杰,

bug description: In my program, expression '$-label' is ok to pass(see attachment 
file line 7&8) assemble, but 'lable-$' cannot pass

It is nothing to do with the $ symbol specifically. Any undefined symbol will give you the same effect. Eg:

  $ cat test.s
        .byte undef - foo
        .byte foo - undef

  % as test.s   
  foo.s: Assembler messages:
foo.s:4: Error: can't resolve `.text' {.text section} - `undef' {*UND* section}

This is a known limitation of the assembler/linker. Essentially the problem is that the linker supports a relocation to compute "symbol - value" but it does not support a relocation to compute "value - symbol".

So the third line in the example source above is resolved by the assembler into a zero byte value and a relocation that computes "undef - 1". But the assembler cannot create a relocation to compute "1 - undef" so it issues the error message.


reply via email to

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