Hi everybody, This is a proposal for a patch set that adds a new -mexecute-only arm option for profile M targets. Some STM32 MCUs implement a security feature called 'Proprietary Code Read-Out Protection' aka PCROP that forbids data read access to some code areas (only fetch access is allowed). This protection prevents usage of literal pools (since one cannot load data from code sections), so compilers have to use a specific code sequence to generate constants. The first patch adds generic support for the new binutils section letter 'y' that allows to specify a section as being no-readable. The second patch adds the new -mexecute-only arm option. This option disables all memory read inside text section, and takes care to emit the corresponding code in 'y' sections.
Unit tests have been written to check for correct code generation. No regressions have been observed for aarch64-none-elf, aarch64-none-linux-gnu, aarch64_be-none-elf, arm-none-eabi, arm-none-linux-gnueabi, arm-none-linux-gnueabihf and armeb-none-linux-gnueabihf. Mickael Guene (2): Add support for section attribute letter 'y' when available Add -mexecute-only option. gcc/config.in | 6 ++ gcc/config/arm/arm-protos.h | 1 + gcc/config/arm/arm.c | 114 +++++++++++++++++++-- gcc/config/arm/arm.md | 2 +- gcc/config/arm/arm.opt | 4 + gcc/config/arm/thumb1.md | 71 +++++++++++-- gcc/configure | 34 +++++- gcc/configure.ac | 6 ++ gcc/doc/invoke.texi | 7 ++ gcc/output.h | 3 +- .../gcc.target/arm/thumb1-execute-only-switch.c | 23 +++++ gcc/testsuite/gcc.target/arm/thumb1-execute-only.c | 69 +++++++++++++ .../gcc.target/arm/thumb2-execute-only-switch.c | 23 +++++ gcc/testsuite/gcc.target/arm/thumb2-execute-only.c | 68 ++++++++++++ gcc/varasm.c | 6 +- 15 files changed, 420 insertions(+), 17 deletions(-) create mode 100644 gcc/testsuite/gcc.target/arm/thumb1-execute-only-switch.c create mode 100644 gcc/testsuite/gcc.target/arm/thumb1-execute-only.c create mode 100644 gcc/testsuite/gcc.target/arm/thumb2-execute-only-switch.c create mode 100644 gcc/testsuite/gcc.target/arm/thumb2-execute-only.c -- 2.7.0.rc3