This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: HELP with linker script!!!
Hi Nick and Grigory,
Thank you very much. Your emails were extremely helpful. I'm trying to
digest it, but it's still a little over my head. I'm a self-confessed
newbie to this area. So I still have a couple of questions ... perhaps
because I still haven't understood your emails entirely:
(1) Is there a name for the stack section and the heap section? What I
mean here is, just like the name for the uninitialized globals is .bss,
is there something like this when referring to the stack? Is this the
hardware specific part? In other words, will the name I need to
reference in the linker script vary depending on what I choose to be my
target as I cross-compile? If so, where specifically should I look to
find this? Would the ABI mention this? Do I use the same syntax to
define the stack's size? and the heap's size?
(2) The reason I'm trying to assign certain variables to memory regions
on their own, is because I have more than just the simple RAM and ROM
region like in the example documentation. In my case, my RAM contains a
region that is cachable and another region that is uncachable (like
scratch memory). What I would like to do is place some of the members
of the .bss section in the uncacheable region and some of the .bss
section in the cachable region. Exactly how I should do this is where
I'm getting stuck. Grigory's email is still over my head in this way
and I'm still trying to "digest" it! Because of I'm not familiar at all
with what he's doing here, I want to make sure his example would serve
my purpose before I go down the wrong track ... can you or someone else
confirm this?
Again thanks so much for your help!
Sincerely,
Pieter
On Mar 31, 2005, at 3:57 AM, Nick Clifton wrote:
Hi Pieter,
I read the the Red Hat manual "Using ld, the GNU Linker",
First of all it is not a Red Hat manual. It is the binutils project's
linker manual. You might have been confused by the fact that the
binutils project is hosted at the sources.redhat.com domain, but this
is a resource provided by Red Hat to the Free Software community and
it does not make the linker or its manual Red Hat property in any way.
but I'm having trouble. Essentially, I'd like to take specific
symbols and assign them to a memory region, rather than just take a
section and assign it to a memory region.
A practical example of the problem that you are trying to solve would
help.
The linker does not have the facility to assign individual symbols to
a memory region. Instead, as Grigory has already mentioned, the way
to achieve what you want is to use a custom section to contain the
symbols that you are interested in, and then have the linker script
assign this custom section to a specific memory region. His email
shows you how to do this.
Additionally, where do I define the start and end regions of my stack
and heap? I use .bss for uninitialized variables, .data for
initialized variables, but how do I reference the beginning and end
of stack and the beginning and end of heap?
That is up to you and will probably be dictated by the hardware you
are using and the amount of available memory. One common design is to
have the heap start at the end of the allocated sections, usually
after the .bss section, and grow upwards through memory. Meanwhile
the stack is placed to start at the end of the available memory and
grow downwards. (This does assume that the ABI for the processor you
are using has a downwards growing stack).
The location for the start of the heap and the start of the stack will
normally be set up by your linker script and so you can associate
symbols with these locations. Finding the current end-of-heap and
end-of-stack however is hardware specific. Usually a hardware
register will be used as a stack pointer and so contain the
end-of-stack address. The end of heap however is usually held in a
private variable somewhere inside the operating system's memory
allocation code and may not be accessible to application programs.
Cheers
Nick