ld, access to symbols

Ian Lance Taylor ian@zembu.com
Fri Jul 9 09:52:00 GMT 1999


   Date: Fri, 09 Jul 1999 10:57:28 +0100
   From: Dominic Hanlan <hanland@mcd.alcatel.be>

   my question is this, is it possible form within a link script to access
   abd manipulate variables from
   an object that is being linked.

   i.e.

   test.c contains int x.

   can I access x in the link script and assign its value to a link script
   global variable.

I'd say the answer is yes, but it depends upon exactly what you mean.

The linker script deals with symbol values.  That means that the value
`x' in a linker script is (in most cases) equal to the value `&x' in
C.  A ``link script global variable'' is a symbol.  You can certainly
assign the value of the symbol x to another symbol in a linker script.

The linker script does not give you any access to the value of a
global variable in the sense of the value of x rather than the address
of x.

Ian


More information about the Binutils mailing list