>How does the linker know where to point to resources such as variables
>etc, I can understand malloc, because you roll you own, but what about
>variables which are allocated by the compiler, linker ?

In Unix style segment location, the linker (ld) starts at the base
address.  This is generally 0 or the the first page boundary (to allow
page 0 to be protected ro and catch some common programming errors) in
the case of binaries running under VM. Then it lays down all the code
(text segment), starting with the runtime startup. It probably rounds up
to the next page boundary at this point. Next it lays down the initialised
data (data segment), then the uninitialised data (bss segment). The heap
starts after the uninitialised data. The stack generally starts at the
top of (virtual, user) memory.

In the embedded case the base address is often not 0. But all you have
to do is tell the linker where to start with the -Ttext, etc. arguments.
In general you don't have to worry about where variables are located,
that's the linker's job.
--
SLUG - Sydney Linux Users Group Mailing List - http://www.slug.org.au
To unsubscribe send email to [EMAIL PROTECTED] with
unsubscribe in the text

Reply via email to