From 0ee70cc0000fe25484cb0d3b2ac2904d2007e5cf Mon Sep 17 00:00:00 2001 From: Andre Vieira Date: Thu, 22 Sep 2016 17:02:47 +0000 Subject: [ARM] Add support for -mpure-code option gcc/ChangeLog: 2016-09-22 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/texi.in (TARGET_ASM_ELF_FLAGS_NUMERIC): Likewise. gcc/testsuite/ChangeLog: 2016-09-22 Andre Vieira Terry Guo * gcc.target/arm/pure-code/ffunction-sections.c: New. * gcc.target/arm/pure-code/no-literal-pool.c: New. * gcc.target/arm/pure-code/pure-code.exp: New. Co-Authored-By: Terry Guo From-SVN: r240379 --- gcc/varasm.c | 50 +++++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 21 deletions(-) (limited to 'gcc/varasm.c') diff --git a/gcc/varasm.c b/gcc/varasm.c index ba866ce..72cba86 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -6256,6 +6256,7 @@ default_elf_asm_named_section (const char *name, unsigned int flags, tree decl) { char flagchars[11], *f = flagchars; + unsigned int numeric_value = 0; /* If we have already declared this section, we can use an abbreviated form to switch back to it -- unless this section is @@ -6268,31 +6269,38 @@ default_elf_asm_named_section (const char *name, unsigned int flags, return; } - if (!(flags & SECTION_DEBUG)) - *f++ = 'a'; + /* If we have a machine specific flag, then use the numeric value to pass + this on to GAS. */ + if (targetm.asm_out.elf_flags_numeric (flags, &numeric_value)) + snprintf (f, sizeof (flagchars), "0x%08x", numeric_value); + else + { + if (!(flags & SECTION_DEBUG)) + *f++ = 'a'; #if defined (HAVE_GAS_SECTION_EXCLUDE) && HAVE_GAS_SECTION_EXCLUDE == 1 - if (flags & SECTION_EXCLUDE) - *f++ = 'e'; + if (flags & SECTION_EXCLUDE) + *f++ = 'e'; #endif - if (flags & SECTION_WRITE) - *f++ = 'w'; - if (flags & SECTION_CODE) - *f++ = 'x'; - if (flags & SECTION_SMALL) - *f++ = 's'; - if (flags & SECTION_MERGE) - *f++ = 'M'; - if (flags & SECTION_STRINGS) - *f++ = 'S'; - if (flags & SECTION_TLS) - *f++ = TLS_SECTION_ASM_FLAG; - if (HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE)) - *f++ = 'G'; + if (flags & SECTION_WRITE) + *f++ = 'w'; + if (flags & SECTION_CODE) + *f++ = 'x'; + if (flags & SECTION_SMALL) + *f++ = 's'; + if (flags & SECTION_MERGE) + *f++ = 'M'; + if (flags & SECTION_STRINGS) + *f++ = 'S'; + if (flags & SECTION_TLS) + *f++ = TLS_SECTION_ASM_FLAG; + if (HAVE_COMDAT_GROUP && (flags & SECTION_LINKONCE)) + *f++ = 'G'; #ifdef MACH_DEP_SECTION_ASM_FLAG - if (flags & SECTION_MACH_DEP) - *f++ = MACH_DEP_SECTION_ASM_FLAG; + if (flags & SECTION_MACH_DEP) + *f++ = MACH_DEP_SECTION_ASM_FLAG; #endif - *f = '\0'; + *f = '\0'; + } fprintf (asm_out_file, "\t.section\t%s,\"%s\"", name, flagchars); -- cgit v1.1