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.
Hi All,
I have a long used project based on GCC compiler(GNU Tools ARM Embedded 4.9 2015q3) directly. (No use the CCS IDE and Arm® code generation tools – compiler )
Recently, I start to consider the security issue, so the Flash unreadable protection operation is added.
After I configure the specified Flash to "Execute Only", then using the JTag to upload it, the value of the specified range is "0".
I think the protection is work!
But the chip will crash when the program execute the protected range.
I refer the below document to test the flash protection feature based on CCS 10.
https://www.ti.com/lit/an/spma044a/spma044a.pdf
It works normal and the chip not crash when execute the protected range.
I think the different of them is that I skip the step of adjusting compiler parameter in first project.
Then I recover the "Specify whether constants can be embedded in the code section (--embedded_constants)" to On in the CCS test project.
The chip also crash when executing the protected flash.
I read the description, and I realize this step is necessary.
After I search the "--embedded_constants", all document are based on "Arm® code generation tools – compiler"
I try to adjust the configuration refer the GCC compiler manual, but it no success.
gcc.gnu.org/.../Option-Summary.html
Could anyone know how to configure the GCC compiler to implement the "--embedded_constants" feature in the "Arm® code generation tools – compiler"?
Best regards.
From looking at https://gcc.gnu.org/onlinedocs/gcc/ARM-Options.html try -mpure-codeMike Chou said:Could anyone know how to configure the GCC compiler to implement the "--embedded_constants" feature in the "Arm® code generation tools – compiler"?
Chester's answer makes sense to me but I am not a GCC expert.
Here are the descriptions of each option to compare.
GCC
Do not allow constant data to be placed in code sections. Additionally, when compiling for ELF object format give all text sections the ELF processor-specific section attribute SHF_ARM_PURECODE
. This option is only available when generating non-pic code for M-profile targets.
TI Arm compiler (armcl)
--embedded_constants={on|off}
By default the compiler embeds constants in functions. These constants can include literals, addresses, strings, etc. This is a problem if you wants to prevent reads from a memory region that contains only executable code. To enable the generation of "execute only code", the compiler provides the --embedded_constants=[on|off] option. If the option is not specified, it is assumed to be on. The option is available on the following devices: Cortex-A8, Cortex-M3, Cortex-M4, and Cortex-R4.
Hi Chester & John,
It works now, thanks a lot.
I want to remind one thing.
The TM4C129ENCPDT is belong to ARM Cortex-M.
"GNU Tools ARM Embedded Toolchain" start to support "-mpure-code" after v6 2016q4 version.
Please refer:
https://launchpad.net/gcc-arm-embedded/+announcement/14413
+ ARM PURECODE support for ARMv7-M and ARMv8-M Mainline
Thanks again for rapidly assistance.
Best regards.