1

I'm trying to figure out how to define a custom output section in my application's LD file. So far, this is what I've come up with...

MEMORY
{
  ...
  m_my_custom_section (RW)  : ORIGIN = 0x00002400, LENGTH = 0x00000400
  ...
}

SECTIONS
{
  ...
  .my_custom_section :
  {
    . = ALIGN(4);
    KEEP(*(.my_custom_section))
    . = ALIGN(4);
  } > m_my_custom_section
  ...
}

Unfortunately, that's where I'm stuck. I'm unsure how to specify which parts of my code I want assigned to that section when the application links. Any help would be great. :)

1 Answer 1

1

I believe I found the answer here in @Mike Kinghan's comment:

In Standard C or C++ there are no syntactic means to define sections. Section definition normally is entirely the compiler's business. A compiler may have non-standard extensions that let you assign an object to a named section. For GCC see the documentation of __attribute__ ((section ("<section-name>"))) in Common Variable Attributes and Common Function Attributes Such extensions are for specialized purposes.

Sign up to request clarification or add additional context in comments.

Comments

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.