Re: [Mspgcc-users] relocation error

2015-02-23 Thread Nicholas Clifton
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
.ifstart == 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 link when  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=190641631iu=/4140/ostg.clktrk
___
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users


[Mspgcc-users] relocation error

2015-02-18 Thread David W. Schultz
Here is a puzzler.

I have been fiddling with a version of Camelforth for the FRAM parts in
an ill fated attempt to port it to the MSP430FR5969. The original code
is for the IAR tools but I use gcc.

After much gnashing of teeth and assorted hacking I have an error that I
don't know how to fix or even if it can be fixed.

The code uses a few macros to automate production of FORTH headers and
the trouble is with the link field which creates a linked list of
headers. Cutting it down to a small program that recreates the error:

.text
.globl main
main:   
.equ link,0
.word  link
.equ link, .
.word  link
.equ link, .
.end

test.S:7: Error: redefined symbol cannot be used on reloc

Line 7 being the second .word link

The really interesting thing is that while this fails on the newfangled
TI version of msp430-elf-gcc, aka:
msp430-elf-gcc (GCC) 4.9.1 20140707 (prerelease (msp430-14r1-167))
(GNUPro 14r1)

It works just fine on my old msp430-gcc. aka:

msp430-gcc (GCC) 4.6.4 20130412 (mspgcc LTS 20120406 unpatched)

Is there something I am doing wrong or did someone break the assembler?


-- 
David W. Schultz
http://home.earthlink.net/~david.schultz
Returned for Regrooving



--
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=190641631iu=/4140/ostg.clktrk
___
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users


Re: [Mspgcc-users] relocation error

2015-02-18 Thread DJ Delorie

Just a request, when reporting errors against the assembler, please
give the assembler's version number, not the compiler's version
number:

$ msp430-elf-as --version
GNU assembler (GNU Binutils) 2.25.51.20150212

FWIW I've reproduced this with the FSF assembler reporte above, which
is the binutils development trunk version.

Also FWIW, I think defining one symbol to have two values is a bad
idea...

--
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=190641631iu=/4140/ostg.clktrk
___
Mspgcc-users mailing list
Mspgcc-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mspgcc-users