public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: "Dave Korn" <dk@artimi.com>
To: <jbeniston@compxs.com>, <binutils@sources.redhat.com>
Subject: RE: MEMORY commands in link scripts
Date: Fri, 05 Nov 2004 12:55:00 -0000	[thread overview]
Message-ID: <NUTMEGmjpD3zCParqjP00000501@NUTMEG.CAM.ARTIMI.COM> (raw)
In-Reply-To: <000d01c4c32e$e2a25d60$0bbda8c0@Kindrogan>

> -----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....

  reply	other threads:[~2004-11-05 12:55 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-05 11:59 Jon Beniston
2004-11-05 12:55 ` Dave Korn [this message]
2004-11-05 13:26   ` Jon Beniston
2004-11-08  8:46     ` Nick Clifton
2004-11-08 11:51       ` Jon Beniston
2004-11-19  9:31         ` Nick Clifton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=NUTMEGmjpD3zCParqjP00000501@NUTMEG.CAM.ARTIMI.COM \
    --to=dk@artimi.com \
    --cc=binutils@sources.redhat.com \
    --cc=jbeniston@compxs.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).