GNU linker script question
CASTalk.com Forum Index CASTalk.com
Discussion of DSP, FPGA, storage and embedded system.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web castalk.com
GNU linker script question

 
Post new topic   Reply to topic    CASTalk.com Forum Index -> Embedded System
Author Message
Jim
Guest





Posted: Sat Dec 10, 2005 1:15 am    Post subject: GNU linker script question Reply with quote

Hi,

I'm working on an embedded project at home using GNU gcc & ld. I need
to burn a function into a particular flash rom address. My attempt
will be to place the function in its own file and define a section
like:

SECTIONS {
MySection 0x10000:
{
MyFile.o
}
_MySectionEnd = . ;
}

Then, in my app, I should be able to refer to _MySectionEnd to get the
end address of the function. I'm pretty sure this, or a variant will
work (my syntax might not be 100% as I'm an ld newbie).

But, is there a better way? Also, while this is OK for one, or a few
functions, it would be a pain if I ever had to do a lot of 'em. I know
there's a "section" attribute for gnu C, so I was wondering if I can
create one or more MySection1 and _MySection1End symbol pairs in a
linker script and somehow place each function at the desired section
while all functions reside in one file?


Thanks for the ideas!



Jim
Back to top
Jim
Guest





Posted: Sun Dec 11, 2005 1:15 am    Post subject: Re: GNU linker script question Reply with quote

Just to avoid a bunch of comments correcting me, the linker script
above turned out to be more like:

.text :
{
MyFunc.o (.text)
_MyFuncEnd = .;
*(.text)
*(.rodata)
. = ALIGN(0x4) ;
__etext = .;
} > ram


Jim

p.s.
I did finally find something about causing gcc to create each function
in it's own section as if it were in its own file, but it didn't say
how you knew what the section names would be. I'm guessing it would be
a derivative of the function name.
Back to top
Guest






Posted: Sun Dec 11, 2005 8:05 am    Post subject: Re: GNU linker script question Reply with quote

Jim <adirondackmtn@yahoo.com> wrote:

Quote:
I know there's a "section" attribute for gnu C, so I was wondering if
I can create one or more MySection1 and _MySection1End symbol pairs in
a linker script and somehow place each function at the desired section
while all functions reside in one file?

Yes, go to <http://www.devrs.com/gba/ccode.php#cmisc> and download the
crtls package for an example of how it can be done.

-a
Back to top
David Brown
Guest





Posted: Mon Dec 12, 2005 9:15 am    Post subject: Re: GNU linker script question Reply with quote

Jim wrote:
Quote:
Just to avoid a bunch of comments correcting me, the linker script
above turned out to be more like:

.text :
{
MyFunc.o (.text)
_MyFuncEnd = .;
*(.text)
*(.rodata)
. = ALIGN(0x4) ;
__etext = .;
} > ram


Jim

p.s.
I did finally find something about causing gcc to create each function
in it's own section as if it were in its own file, but it didn't say
how you knew what the section names would be. I'm guessing it would be
a derivative of the function name.


If you are only looking for the end address of a single function, then
you could put that function in its own named section (look in the gcc
manual for "function attributes"). I've done this on several targets
for putting flash routines in a separate section so that they run from
ram rather than flash.
Back to top
Jim
Guest





Posted: Wed Dec 14, 2005 12:50 am    Post subject: Re: GNU linker script question Reply with quote

ammonton@cc.full.stop.helsinki.fi wrote:
Quote:
Jim <adirondackmtn@yahoo.com> wrote:

I know there's a "section" attribute for gnu C, so I was wondering if
I can create one or more MySection1 and _MySection1End symbol pairs in
a linker script and somehow place each function at the desired section
while all functions reside in one file?

Yes, go to <http://www.devrs.com/gba/ccode.php#cmisc> and download the
crtls package for an example of how it can be done.

-a

That's an interesting site. Thanks.


Jim
Back to top
 
Post new topic   Reply to topic    CASTalk.com Forum Index -> Embedded System All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




VoIP Electronics Powered by phpBB