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: V850, linker problem


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


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