# Writing a Function at specific memory location of Flash

I want a function to go at specific memory location of Flash and I am not able to figure it out.

Do I need to do modification in Linker File?

Also, I have idea that in GCC, I would use #pragma directives by which I can put my code in specific section but don't know how to assign that section to specific address.

I am using Keil and programming LPC2138.

To put a function in a section with GCC, use a function attribute

extern void foobar (void) __attribute__ ((section ("bar")));


Then, declare a section called bar in your linker script. Eg.

MEMORY
{