...place code and data into different sections?
How do I put code and data into different sections?
There are four ways to put code and data into different named sections:
-
If you are using C/C++ you can use gcc's section attribute. The following function declaration will place the function func into the section named .foo:
void func(void) __attribute__ ((section(".foo"))); -
The following variable definition will place the variable var into the section named .bar:
unsigned int var __attribute__ ((section(".bar"))); -
If you are using the assembler you can use a .section directive in place of a .text or .data directive. For example to place code into a section named .foo:
.section .foo, "ax"
func:
add r0, r0, #1
bx lrTo place data into a section named .bar:
.section .bar, "a"
var:
.word 0 -
Change a section's name for an entire module using the Section Name project properties. For example to put all code from a particular module into the section ".foo":
- Select project element in project window.
- Open the element's Properties window.
- Select the Section tab.
- Change the Code Section Name from ".text" to ".foo".
Please sign in to leave a comment.
Comments
5 comments