Re: How to tell the linker to place the particular function at the specified address?

DJ Delorie <[email protected]>
Newsgroups gmane.comp.hardware.texas-instruments.msp430.gcc.user
Message-ID <[email protected]>
In general (i.e. untested ;) you'd add a linker script snippet like
this:

section_TAO 0xC400 : {
  *(.myfuncsec_TAO)
}

Then tag your function with a section attribute:

static void __interrupt __attribute__((section(".myfuncsec_TAO")))
Timer0_A0_alter(void)
{
}


The key here is that you can change the section a function (or
anything, like data or tables) is in, and the linker knows how to put
specific sections at specific addresses.

Note that this only works if *other* output sections in the link do
not overlap.  I typically avoid the examples above, and instead use
memory regions, that way I know they won't overlap or overflow.

MEMORY {
        MYFUNCSEC (r) : ORIGIN = 0x0c400, LENGTH = 0x00400
}

section_TAO : {
  *(.myfuncsec_TAO)
} > MYFUNCSEC


Note that you can also do per-file placement, by replacing the '*' wildcard
with the file name you want:

section_TAO {
  int_a0.o(.text)
} > MYFUNCSEC

but if there are other .text things in that object that you're not
aware of, that won't guarantee that the specific handler is at the
address you want.

------------------------------------------------------------------------------
Managing the Performance of Cloud-Based Applications
Take advantage of what the Cloud has to offer - Avoid Common Pitfalls.
Read the Whitepaper.
http://pubads.g.doubleclick.net/gampad/clk?id=121054471&iu=/4140/ostg.clktrk
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.