This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Change sections of a .obj after build

Hello,

I would like to know if there is a way to change a certain section of a .obj file to another.

For example, I want all the ".ebss" variables of that .obj file to be placed into ".mysection". Is there a simple way to do it instead of using #pragma DATA_SECTION() all over the source file?

Many thanks for your  help!

  • You can do something similar in the linker command file.  In the SECTIONS directive you can write ...

    my_section { file_name.obj(.ebss) } > MEMORY_RANGE

    This says to create an output section named my_section.  It has one input section, the .ebss section from file_name.obj.  Place my_section into the memory range named MEMORY_RANGE.

    Thanks and regards,

    -George

  • Dear George,

    Excellent, that works perfectly! It's exactly what I needed!

    Thanks a lot!