LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-18-2005, 01:16 AM   #1
funkymunky
Member
 
Registered: Jun 2003
Location: Austin, Texas
Distribution: Fedora Core 8, 32-bit
Posts: 126

Rep: Reputation: 15
Unhappy Doubt about how a linker builds a memory image


Hi everyone,

I have a doubt regarding the way a memory image is build by the linker (ld, in my case) with the output files. I dont have a Comp.Sc background, so i havent studied these things formally.

Suppose i have 2 kb of code i want to load into memory (0x0 to 0x800000 ). The output has two sections of 1kb each, one of which has to be put on location 0x200000 and the other on location 0x600000. Howdoes the linker ensure that the correct data is put at the correct location? I mean, does it generate a huge image of size 0x600000 + 1kb that has data at the correct locations, and the intermediate spaces padded?? what sends the data finally to the correct location?

Plz help!

Thanx in anticipation,

Mayank
thoroughly
 
Old 02-18-2005, 08:04 AM   #2
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
Where do you get the idea that the sections have to be loaded at different memory addresses? The only thing that I'm aware of that's consistent is the starting address of every program in virtual memory.
 
Old 02-18-2005, 10:46 AM   #3
funkymunky
Member
 
Registered: Jun 2003
Location: Austin, Texas
Distribution: Fedora Core 8, 32-bit
Posts: 126

Original Poster
Rep: Reputation: 15
doh!

Lets forget about virtual memory for a while..im talking about microcontrollers running without an OS..im working on the Atmel At91rm9200, that has a little RAM and no Flash. I may have the code (.text) section at one memory location and a data section at another location.
 
Old 02-18-2005, 11:48 AM   #4
itsme86
Senior Member
 
Registered: Jan 2004
Location: Oregon, USA
Distribution: Slackware
Posts: 1,246

Rep: Reputation: 59
According to ld's man page you can use:
Code:
       --section-start sectionname=org
           Locate a section in the output file  at  the  absolute
           address given by org.  You may use this option as many
           times as necessary to locate multiple sections in  the
           command  line.  org must be a single hexadecimal inte-
           ger; for compatibility with  other  linkers,  you  may
           omit  the leading 0x usually associated with hexadeci-
           mal values.  Note: there  should  be  no  white  space
           between sectionname, the equals sign (``=''), and org.
 
Old 02-18-2005, 11:59 AM   #5
funkymunky
Member
 
Registered: Jun 2003
Location: Austin, Texas
Distribution: Fedora Core 8, 32-bit
Posts: 126

Original Poster
Rep: Reputation: 15
okay, now u and i are on the same wavelength..
My doubt was..How is the option uve mentioned above IMPLEMENTED by the linker? How does it make sure that the data will actually be at these locations once its loaded into the uC? What is there in the space between these sections??

Regards
Mayank
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Where can I find the nightly builds? linuxnube Fedora 3 03-14-2005 07:13 AM
XFree ghost image video memory d_t_baker Linux - Software 1 03-06-2005 12:09 PM
latest kernel builds bmorgan98 Linux - Newbie 4 07-17-2004 05:18 PM
Re: Slackware Builds NecroScumBag Slackware 1 04-13-2004 04:33 PM
rebooting during builds general4172 Linux - Software 4 08-25-2003 10:23 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration