From: Nick Clifton <nickc@redhat.com>
To: Pieter Arnout <pieter@powerescape.com>
Cc: binutils@sources.redhat.com
Subject: Re: HELP with linker script!!!
Date: Mon, 04 Apr 2005 11:06:00 -0000 [thread overview]
Message-ID: <42511F17.5030705@redhat.com> (raw)
In-Reply-To: <c0be1d23b46c1b33af576292896526b6@powerescape.com>
Hi Pieter,
> Thank you so much. Your email was *extremely* helpful! Your explanations
> are excellent! I greatly appreciate all of your help!
Umm thank you - just one request - please could you use fewer
exclamation marks ? Thanks.
> (1) How do I indicate the start and end of the cacheable .bss or
> uncacheable .bss in your example? Don't they usually have symbol names
> that you can use to refer to them by?
You put the symbols in the linker script, like this:
.cached_bss : {
__start_of_cacheable_bss = ABSOLUTE (.);
*(.cached_bss)
__end_of_cacheable_bss = ABSOLUTE (.);
} > cachableRAM;
Then you can reference them from your C code, like this:
extern int __start_of_cacheable_bss;
extern int __end_of_cacheable_bss;
memset (& __start_of_cacheable_bss, 0,
& __end_of_cacheable_bss - & __start_of_cacheable_bss);
Note - read the section entitled "Source Code Reference" in the linker
documentation for an explanation of why these variables are being
accessed via the & operator.
Note - you do not need to use double underscores at the start of the
variable names, this is just a convention.
>> Normally the stack and heap do not have a size. Instead they occupy
>> all of the memory available to the application which has not already
>> been allocated to the loaded code and its data.
>
> This makes no sense to me. Frequently the stack and heap grow towards
> each other, so isn't it important to define a boundary which they cannot
> cross?
No - as otherwise you would be restricting the heap and stack to fixed
sizes when it was not necessary. Some applications may use a lot of
stack but very little heap, and others might use lots of heap but only a
little stack. If you have a fixed boundary that the stack and heap
cannot cross then you might be unable to accommodate these kinds of
application.
> How can they not have a size then?
They do have sizes, but not fixed ones. Their sizes are dynamic with
the only real limitation being the amount of available memory that can
be shared between them.
> Do they just grow towards each
> other until one collides with the other?
Yes. Of course well written memory allocators will attempt to check for
collision with the stack. Also for some targets the compiler supports a
command line switch to add extra code that is called at the start of
every function in order to check whether the stack is about to overflow
into the heap.
Cheers
Nick
next prev parent reply other threads:[~2005-04-04 11:06 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-03-31 14:42 Pieter Arnout
2005-03-31 15:50 ` Nick Clifton
[not found] ` <29c1ff0410ff9cc2b88a3ad82d1938aa@powerescape.com>
2005-04-01 11:27 ` Nick Clifton
2005-04-01 12:53 ` Vincent Rubiolo
2005-04-01 14:05 ` Nick Clifton
2005-04-01 14:13 ` Dave Korn
2005-04-01 14:34 ` Andreas Schwab
2005-04-01 16:53 ` Pieter Arnout
2005-04-04 9:39 ` Vincent Rubiolo
2005-04-04 11:06 ` Nick Clifton [this message]
2005-04-04 11:11 ` Dave Korn
2005-04-04 11:59 ` Sergei Organov
2005-04-04 13:39 ` Nick Clifton
2005-03-31 15:08 Zagorodnev, Grigory
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=42511F17.5030705@redhat.com \
--to=nickc@redhat.com \
--cc=binutils@sources.redhat.com \
--cc=pieter@powerescape.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).