diff options
author | Haochen Gui <guihaoc@gcc.gnu.org> | 2020-11-17 13:52:15 -0600 |
---|---|---|
committer | Haochen Gui <guihaoc@gcc.gnu.org> | 2020-11-17 13:53:14 +0800 |
commit | d5ac0401eb128bf3dadec943741dfde7c499e49a (patch) | |
tree | 9f7cce8cbdbd8438af547d8584dea1b25ba77185 /gcc/final.c | |
parent | 287cc750b0887e86cb309d976b17c7ee95f7ad48 (diff) | |
download | gcc-d5ac0401eb128bf3dadec943741dfde7c499e49a.zip gcc-d5ac0401eb128bf3dadec943741dfde7c499e49a.tar.gz gcc-d5ac0401eb128bf3dadec943741dfde7c499e49a.tar.bz2 |
Relocatable read-only section support for absolute jump table
This patch puts absolute jump tables into a relocatable read-only section
if they are on ELF target and relocation is supported.
gcc/ChangeLog:
* final.c (final_scan_insn_1): Set jump table relocatable as the
second argument of targetm.asm_out.function_rodata_section.
* output.h (default_function_rodata_section,
default_no_function_rodata_section): Add the second argument to the
declarations.
* target.def (function_rodata_section): Change the doc and add
the second argument.
* doc/tm.texi: Regenerate.
* varasm.c (jumptable_relocatable): Implement.
(default_function_rodata_section): Add the second argument
and the support for relocatable read only sections.
(default_no_function_rodata_section): Add the second argument.
(function_mergeable_rodata_prefix): Set the second argument to false.
* config/mips/mips.c (mips_function_rodata_section): Add the second
arugment and set it to false.
* config/s390/s390.c (targetm.asm_out.function_rodata_section): Set
the second argument to false.
* config/s390/s390.md: Likewise.
Diffstat (limited to 'gcc/final.c')
-rw-r--r-- | gcc/final.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/gcc/final.c b/gcc/final.c index 80423d1..fc9a05e 100644 --- a/gcc/final.c +++ b/gcc/final.c @@ -81,6 +81,7 @@ along with GCC; see the file COPYING3. If not see #include "rtl-iter.h" #include "print-rtl.h" #include "function-abi.h" +#include "common/common-target.h" #ifdef XCOFF_DEBUGGING_INFO #include "xcoffout.h" /* Needed for external data declarations. */ @@ -2154,6 +2155,21 @@ asm_show_source (const char *filename, int linenum) fputc ('\n', asm_out_file); } +/* Judge if an absolute jump table is relocatable. */ + +bool +jumptable_relocatable (void) +{ + bool relocatable = false; + + if (!CASE_VECTOR_PC_RELATIVE + && !targetm.asm_out.generate_pic_addr_diff_vec () + && targetm_common.have_named_sections) + relocatable = targetm.asm_out.reloc_rw_mask (); + + return relocatable; +} + /* The final scan for one insn, INSN. Args are same as in `final', except that INSN is the insn being scanned. @@ -2493,7 +2509,8 @@ final_scan_insn_1 (rtx_insn *insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED, int log_align; switch_to_section (targetm.asm_out.function_rodata_section - (current_function_decl)); + (current_function_decl, + jumptable_relocatable ())); #ifdef ADDR_VEC_ALIGN log_align = ADDR_VEC_ALIGN (table); @@ -2572,7 +2589,8 @@ final_scan_insn_1 (rtx_insn *insn, FILE *file, int optimize_p ATTRIBUTE_UNUSED, if (! JUMP_TABLES_IN_TEXT_SECTION) switch_to_section (targetm.asm_out.function_rodata_section - (current_function_decl)); + (current_function_decl, + jumptable_relocatable ())); else switch_to_section (current_function_section ()); |