]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Darwin: Match system sections and relocs for exception tables.
authorIain Sandoe <iain@sandoe.co.uk>
Thu, 31 Aug 2023 18:20:43 +0000 (19:20 +0100)
committerIain Sandoe <iain@sandoe.co.uk>
Thu, 18 Apr 2024 14:46:19 +0000 (15:46 +0100)
System tools from Darwin10 onwards have moved the exceptions tables from
the __DATA segment to the __TEXT one.  They also revised the relocations
used for typeinfo.  While Darwin9 was not changed at the time, in fact the
tools there are equally happy with the revised scheme - and therefore at
present there seems no reason to special-case it.

Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/ChangeLog:

* config/darwin-sections.def (darwin_exception_section): Move to
the __TEXT segment.
* config/darwin.cc (darwin_emit_except_table_label): Align before
the exception table label.
* config/darwin.h (ASM_PREFERRED_EH_DATA_FORMAT): Use indirect PC-
relative 4byte relocs.

(cherry picked from commit 0fe7962afc7c01488432b98b6f442b24946a490d)

gcc/config/darwin-sections.def
gcc/config/darwin.cc
gcc/config/darwin.h

index 394ea1658803be947afb9e49b6d6b07e2b47dc8c..cdd5985cc368e3f36f012250e797947da7e117b9 100644 (file)
@@ -157,7 +157,7 @@ DEF_SECTION (machopic_picsymbol_stub3_section, SECTION_NO_ANCHOR,
 
 /* Exception-related.  */
 DEF_SECTION (darwin_exception_section, SECTION_NO_ANCHOR,
-            ".section __DATA,__gcc_except_tab", 0)
+            ".section __TEXT,__gcc_except_tab", 0)
 DEF_SECTION (darwin_eh_frame_section, SECTION_NO_ANCHOR,
             ".section " EH_FRAME_SECTION_NAME ",__eh_frame"
             EH_FRAME_SECTION_ATTR, 0)
index 919ddb087041ea9e3ec99da565f1e0f670b17d0d..8aa10153cded4d66f7c8573ed905c14abd186d4a 100644 (file)
@@ -2245,6 +2245,7 @@ darwin_emit_except_table_label (FILE *file)
 {
   char section_start_label[30];
 
+  fputs ("\t.p2align\t2\n", file);
   ASM_GENERATE_INTERNAL_LABEL (section_start_label, "GCC_except_table",
                               except_table_label_num++);
   ASM_OUTPUT_LABEL (file, section_start_label);
index 6b81820072ba21399d6fc706967c3bacece7278f..7026d200d591fca3bab1e0821f60a69ea73ebcae 100644 (file)
@@ -1112,7 +1112,7 @@ enum machopic_addr_class {
 
 #undef ASM_PREFERRED_EH_DATA_FORMAT
 #define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL)  \
-  (((CODE) == 2 && (GLOBAL) == 1) \
+  (((CODE) == 2 && (GLOBAL) == 1) || ((CODE) == 0 && (GLOBAL) == 1) \
    ? (DW_EH_PE_pcrel | DW_EH_PE_indirect | DW_EH_PE_sdata4) : \
      ((CODE) == 1 || (GLOBAL) == 0) ? DW_EH_PE_pcrel : DW_EH_PE_absptr)