This is the mail archive of the binutils@sources.redhat.com 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: MEMORY commands in link scripts


> -----Original Message-----
> From: binutils-owner On Behalf Of Jon Beniston
> Sent: 05 November 2004 11:59

> Hi,
> 
> Is there any way to either use non-constants for the ORIGIN 
> or LENGTH values
> in a MEMORY command, or some how access these values else 
> where in a link script. 

  Alas no.  Although the documentation suggests this should be possible, it
isn't.  See

http://sources.redhat.com/ml/binutils/2004-03/msg00540.html
http://sources.redhat.com/ml/binutils/2004-03/msg00571.html

for detailed explanation.  The docs should be updated.  I've filed a
bugzilla report.  Should have done so months ago.  Sorry all.

http://sources.redhat.com/bugzilla/show_bug.cgi?id=518

  Your best bet would be to work around it in your build system, perhaps by
building a linker script as a make target, or perhaps you could use multiple
-T options, and do something like

echo "base = ${BASE}" > ldscript.tmp
echo "size = ${SIZE}" >> ldscript.tmp
echo "MEMORY {" >> ldscript.tmp
echo "  ram (rw) : ORIGIN = ${BASE}, LENGTH = ${SIZE};" >> ldscript.tmp
echo "}" >>ldscript.tmp

then have a main linker script that has all the unchanging parts in it:

--------------------ldscript.main--------------------

  .... 

SECTIONS {
   PROVIDE(_fstack = base + size - 4)
}

  .... 

--------------------ldscript.main--------------------

and on your link command line, use "-T ldscript.tmp -T ldscript.main" to
assemble the two parts into one script.

    cheers, 
      DaveK
-- 
Can't think of a witty .sigline today....


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