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: HELP with linker script!!!


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


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