public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Re: V850, linker problem
       [not found] <200604300855.32560.tmohr@s.netic.de>
@ 2006-05-01 18:52 ` Torsten Mohr
  2006-05-02 10:44   ` Nick Clifton
  0 siblings, 1 reply; 2+ messages in thread
From: Torsten Mohr @ 2006-05-01 18:52 UTC (permalink / raw)
  To: binutils

Hi,

i think the problem described is the following:

  .tdata ALIGN (4) :
  {
	PROVIDE (__ep = .);
	*(.tbyte)
	*(.tcommon_byte)
	*(.tdata)
	*(.tbss)
	*(.tcommon)
  } >RAM AT>rom

__ep should be in RAM, but as "." is in ROM at the moment
the error message is:
address 0x75ec of hw2.elf section .tdata is not within region RAM

Is this assumption correct?

I define some memory regions in the beginning of the linker
script, shouldn't "ld" have one "." per memory region defined?

How can i tell "ld" that "." refers to the "." of RAM?


Thanks fpr any hints,
Torsten.



> Hi,
>
> i asked for this previously on the newlib mailing list, but
> a it is related to linking i think it is placed here much better.
>
> I configured and installed a GNU cross toolchain for V850E.
>
> I want to develop for an embedded controller with specific
> memory layout.
>
> I first tried linking like this:
> $(F_ELF) $(F_MAP) : $(OBJ)
> 	$(CC) -o $(F_ELF) \
> 	-Wl,-Map=$(F_MAP) \
> 	-Wl,--section-start=.vectors=0x000000 \
> 	-Wl,--section-start=.text=0x000640 \
> 	-Wl,--section-start=.data=0x03ffe000 \
> 	-Wl,--section-start=.stack=0x03fffc00 \
> 	$(OBJ)
>
> But when creating sn SREC file i get data that is placed in RAM.
>
> I googled for this problem and got the hint ">ram AT>rom".
>
> So i created a linker script based on the original v850.x.
> I attached it to this mail.
>
> In that script there is a part like this:
>
>   .tdata ALIGN (4) :
>   {
> 	PROVIDE (__ep = .);
> 	*(.tbyte)
> 	*(.tcommon_byte)
> 	*(.tdata)
> 	*(.tbss)
> 	*(.tcommon)
>   } >ram AT>rom
>
> In here there is real RAM (.tbss) and ROM/RAM (.tdata) mixed.
>
> At linking i get:
> v850e-unknown-elf-gcc -o hw2.elf \
> 	-Wl,-Map=hw2.map \
> 	-Wl,-Tv850.x \
> 	main.o vectors.o
> c:\v850e\bin\..\lib\gcc\v850e-unknown-elf\3.4.6\..\..\..\..
> \v850e-unknown-elf\bin\ld.exe: \
> address 0x75ec of hw2.elf section .tdata is not within region ram
> c:\v850e\bin\..\lib\gcc\v850e-unknown-elf\3.4.6\..\..\..\..
> \v850e-unknown-elf\bin\ld.exe: \
> address 0x75f0 of hw2.elf section .sdata is not within region ram
>
> So i've splitted those sections into two parts:
>
>   .tdata_ram ALIGN (4) :
>   {
> 	PROVIDE (__ep = .);
> 	*(.tbyte)
> 	*(.tcommon_byte)
> 	*(.tbss)
> 	*(.tcommon)
>   } >ram
>
>   .tdata_rom ALIGN (4) :
>   {
> 	*(.tdata)
>   } >ram AT>rom
>
> But i still get the same error.
>
>
> Can anybody give me a hint on how to link a program for a V850?
>
>
> Best regards,
> Torsten.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: V850, linker problem
  2006-05-01 18:52 ` V850, linker problem Torsten Mohr
@ 2006-05-02 10:44   ` Nick Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2006-05-02 10:44 UTC (permalink / raw)
  To: Torsten Mohr; +Cc: binutils

Hi Torsten,

>   .tdata ALIGN (4) :
>   {
> 	PROVIDE (__ep = .);
> 	*(.tbyte)
> 	*(.tcommon_byte)
> 	*(.tdata)
> 	*(.tbss)
> 	*(.tcommon)
>   } >RAM AT>rom
> 
> __ep should be in RAM, but as "." is in ROM at the moment
> the error message is:
> address 0x75ec of hw2.elf section .tdata is not within region RAM
> 
> Is this assumption correct?

No.  The error message is not related to the use of ".".

Note, that the use of linker script variables can be quite unintuitive. 
  For example, in the above script fragment, the *value* of the __ep 
variable (if it is generated by the linker script and not provided by an 
object file or on the linker command line) will always be 0.  This is 
because the *value* of "." inside a section is always the offset of the 
current location from the start of the section.  Since the definition 
occurs at the start of the .tdata section's description the offset will 
be 0.  But... the *address* of the __ep symbol will be the address of 
the start of the .tdata section, in the "ram" memory region.  That is 
the address of the symbol is it's address at run-time not load-time. 
(In linker script terminology it is its VMA address not its LMA 
address).  Thus the *address* of __ep will be in RAM not ROM.

> I define some memory regions in the beginning of the linker
> script, shouldn't "ld" have one "." per memory region defined?

Yes and no.  The linker maintains a location counter for each memory 
region defined.  (Plus an extra one for sections which are not assigned 
to any particular memory region).  When an output section is assigned to 
a memory region it is inserted into the region at the location counter 
for that region, and the counter is increased.

But, when the special symbol "." is referenced inside a linker script it 
  always has a well defined value.  If it is referenced inside a 
description of a particular section then its value is the offset from 
the start of that section.  If it is referenced outside of a particular 
section description (but still inside the SECTIONS construct in the 
linker script) then its value is the absolute, run-time address that has 
been reached by the linker as it follows the script and lays out the 
sections in memory.

Cheers
   Nick

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-05-02 10:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <200604300855.32560.tmohr@s.netic.de>
2006-05-01 18:52 ` V850, linker problem Torsten Mohr
2006-05-02 10:44   ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).