This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][ARM] -mpure-code option for ARM

Hi Andre,

 I think you have a typo in your patch. I need to change :
+ text_section-> = "\t.section .text,\"0x20000006\",%%progbits";

+ text_section-> = "\t.section .text,\"0x20000006\",%progbits";

to make it works.


On 06/30/2016 04:32 PM, Andre Vieira (lists) wrote:

This patch adds the -mpure-code option for ARM. This option ensures
functions are put into sections that contain only code and no data. To
ensure this throughout compilation we give these sections the ARM
processor-specific ELF section attribute "SHF_ARM_PURECODE". This option
is only supported for non-pic code for armv7-m targets.

This patch introduces a new target hook 'TARGET_ASM_ELF_FLAGS_NUMERIC'.
This target hook enables a target to use the numeric value for elf
section attributes rather than their alphabetical representation. If
'default_elf_asm_named_section', will print the numeric value of the
section attributes for the current section. This target hook has two
unsigned int FLAGS, the input parameter that tells the function the
current section's attributes;
unsigned int *NUM, used to pass down the numerical representation of the
section's attributes.

The default implementation for TARGET_ASM_ELF_FLAGS_NUMERIC will return
false, so existing behavior is not changed.

Bootstrapped and tested for arm-none-linux-gnueabihf. Further tested for
arm-none-eabi with a Cortex-M3 target.

2016-06-30  Andre Vieira  <>
            Terry Guo  <>

        * target.def (elf_flags_numeric): New target hook.
        * targhooks.h (default_asm_elf_flags_numeric): New.
        * varasm.c (default_asm_elf_flags_numeric): New.
          (default_elf_asm_named_section): Use new target hook.
        * config/arm/arm.opt (mpure-code): New.
        * config/arm/arm.h (SECTION_ARM_PURECODE): New.
        * config/arm/arm.c (arm_asm_init_sections): Add section
          attribute to default text section if -mpure-code.
          (arm_option_check_internal): Diagnose use of option with
          non supported targets and/or options.
          (arm_asm_elf_flags_numeric): New.
          (arm_function_section): New.
          (arm_elf_section_type_flags): New.
        * config/arm/elf.h (JUMP_TABLES_IN_TEXT_SECTION): Disable
          for -mpure-code.
        * gcc/doc/texi (TARGET_ASM_ELF_FLAGS_NUMERIC): New.
        * gcc/doc/ (TARGET_ASM_ELF_FLAGS_NUMERIC): Likewise.

2016-06-30  Andre Vieira  <>
            Terry Guo  <>

        * New.
        * New.
        * New.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]