This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.

See the CrossGCC FAQ for lots more information.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Linker Script Questions


As a "newbie" to embedded programming, I've run into several questions about cross compilation having to do with the GNU linker. I'm trying to write a linker script and I'm having trouble with the following:

(1) I want to define a ROM and RAM memory region with part of the RAM memory region as cacheable and the other part as having an uncacheable path to the CPU. Defining the ROM region seems quite easy, but how do I define the cacheable and uncacheable RAM regions. Again, here's what I want:

      | - ROM
CPU-| - Uncached RAM region
      | - Cache - Cached RAM region

From the looks of it, it would appear to be rather simple to do the ROM and uncached RAM, but that's where I get confused. So, here's what I would write:

MEMORY
{
ram: ORIGIN = /* ???????? */
ram: ORIGIN = [start address in hex], LENGTH = [size of ram, eg: 512K or 8M] /*cached*/
rom: ORIGIN = [start address in hex], LENGTH = [size of rom]
}


QUESTIONS:
- What do I do here?
- Do I define the cache as well?
- How does the linker script know which region is cacheable? Does it NOT need to know?
Based on these questions, I wonder about how a more complex memory hierarchy might be defined in a linker script. For example:
- What happens if I have two levels of cache and one RAM region operates from out of the second level cache, while another RAM region can only be cached through level 1.


(2) I wish to create a slightly complex memory map. I think I can accomplish most of this using the SECTIONS command in the linker script, but I'd like to make sure I can accomplish the things I wish to do therein. Specifically, I wish to:
- Place certain globals in the uncached RAM and others in the cached RAM (read above to understand the memory hierarchy I'm hoping to attain).
- Create several memory pools, so that I can dynamically allocate memory (when necessary) from both the uncached and cached RAM regions.


QUESTIONS:
- Can I do assign some globals to one region and others to another region, or must I assign all globals to one memory region?
- Not knowing much about memory pools, but having looked at Bill Gatliff's article on Embedding GNU, Newlib, Part 2, what must I do in the linker script to create these pools?
- How, then, can I create one pool for the uncached RAM, and another pool to work out of the cacheable RAM space?
- Obviously, I'll have to write some pool alloc and free functions, but is a memory pool just a global array from which I can grab/allocate memory?
- What does this all look like in the linker script?
- It is my understanding that the heap and stack are defined in this part of the linker script. How does this affect my heap definition using the SECTIONS command?


I apologize in advance if these questions are answered already somewhere, but I'm having trouble figuring some of this stuff out. It would be easier if the memory hierarchy I wish to work out of wasn't so complex, but ... Also, I have emailed several people about this already, but I don't want to keep pestering them with questions, so I thought an email to a mailing list might be more appropriate.

Thanks to anyone who can help me to get answers to the questions I have.

Sincerely,
Pieter


------ Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com


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