4
\$\begingroup\$

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.

\$\endgroup\$

1 Answer 1

4
\$\begingroup\$

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
{
  FLASH (rx): ORIGIN=0xDEADBEEF, LENGTH=0x80000000
}

SECTIONS
{
  .bar:
  {
    KEEP(*(.bar))
  } > FLASH
}
\$\endgroup\$
2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.