Placing functions and data at specific addresses

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:

__attribute__ ((section (".bootloader")))

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.

void boot(void) __attribute__ ((section (".bootloader")));

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:

-Wl,--section-start=.bootloader=0x1E000

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.

 

이 블로그의 인기 게시물

SmartFusion2 SoC FPGA - arm CortexM3

ST MCU 국문 기술 자료 사이트

[스크랩] 반도체의 기본재료, 웨이퍼(Wafer)