]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - gcc/final.c
Relocatable read-only section support for absolute jump table
[thirdparty/gcc.git] / gcc / final.c
index 80423d117d9c11b612de67b68ee06826010bed8b..fc9a05e335f47a8a8e21cdb9c4ed9105a8db0d53 100644 (file)
@@ -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 ());