Hi David,

>       .text
>         .equ link,0
>         .word      link
>         .equ     link, .
>         .word      link
>
> test.S:7: Error: redefined symbol cannot be used on reloc

The error message is occurring because of a limitation of the assembler. 
  For any given symbol it only maintains one value.  Redefining the 
symbol (and then using it) is OK provided that the new value is 
absolute, but if it is something that the assembler cannot compute at 
assemble-time you get this error message.


> It works just fine on my old msp430-gcc. aka:
> Is there something I am doing wrong or did someone break the assembler?

Break - no, change yes.  The problem is that the linker now performs 
some code optimizations (referred to as "relaxations") such as converting:

        jnz $+6
         br  label

into:

         jz  label

provided that "label" is within range of the JZ instruction.

But this means that the *size* of the .text section can change, and so 
any value that is PC-relative has to be computed by the linker, not the 
assembler.

What happened with the old msp430-gcc assembler was that it was able to 
convert:

    .text
    .equ  link, 0
    .word link
    .equ  link, .
    .word link

into:

    .text
    .word  0
    .word .text + 2

ie it replaced references to "link" with references to an absolute value 
and a section relative value.  But the new assembler cannot do this as 
".text + 2" might no longer be the correct value for that location.

So - what can you do ?

Well, if you do not need these headers to be in the .text section then 
you can just move them to the .data section:

   .data
   .equ  link, 0
   .word link
   .equ  link, .
   .word link

This assembles just fine.  (The assembler knows that the linker will not 
change the size of the .data section so it is free to replace symbol 
references with section relative references).


Or you could use multiple symbols, rather than just redefining the same 
symbol.  For example:

        .macro foo start=0
        .if    start == 1
        .equ   link\@, 0
        .else
        .equ   link\@, .
        .endif
        .word  link\@
        .endm
        
        .text
        .globl main
main:
        
        foo 1
        foo
        foo 0

This creates lots of symbols called linkNNNN when NNNN is the invocation 
count of the foo macro.

I hope that this helps.

Cheers
   Nick



------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=190641631&iu=/4140/ostg.clktrk
_______________________________________________
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users

Reply via email to