From : http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0474f/BABDJCAA.html
#include <stdio.h>
extern int sqr(int n1);
int gSquared __attribute__((at(0x5000))); // Place at 0x5000
int main()
{
gSquared=sqr(3);
printf("Value squared is: %d\n", gSquared);
}
From : http://www.keil.com/forum/13981/function-located-to-a-fixed-address/
void CANLoadFlash(void) __attribute__((section("ISP_SECTION __at_(0xf000)")));
From : https://www.microchip.com/webdoc/AVRLibcReferenceManual/FAQ_1faq_reloc_code.html
First, the code should be put into a new named section. This is done with a section attribute:
In this example, .bootloader is the name of the new section. This attribute needs to be placed after the prototype of any function to force the function into the new section.
To relocate the section to a fixed address the linker flag --section-start is used. This option can be passed to the linker using the -Wl compiler option:
The name after section-start is the name of the section to be relocated. The number after the section name is the beginning address of the named section.