[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-gcc-list] Fixing function locations

From: E. Weddington
Subject: Re: [avr-gcc-list] Fixing function locations
Date: Wed, 07 Jan 2004 09:54:23 -0700

On 7 Jan 2004 at 16:36, Tom Maughan wrote:

> Is it possible to fix the location of a function to a specific flash address?
> I'm writing some bootloader code which no doubt will get changed in the
> future but I'd like to fix certain externally accessable functions to
> specific address locations such that if I run maincode designed for a
> newer version of the bootloader it won't die horribly.
> Many thanks,

In brief, place your function(s) in it's own named section and then relocate 
that section to the desired address.

To put a function in a named section, you do it with a GCC function attribute:
__attribute__ ((section (".foo")))

Place the attribute after the function prototype. See the GCC user manual for 
more information.

To relocate a section, you can do this with GCC flags:
The -Wl passes the comma delimited flag list to the linker.
The .foo is the name of the section.
The hex number is the address you want to the section to start at.
See the ld (linker) user manual for more info.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]