public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [pushed] Darwin: Match system sections and relocs for exception tables.
@ 2023-09-04 10:57 Iain Sandoe
  0 siblings, 0 replies; only message in thread
From: Iain Sandoe @ 2023-09-04 10:57 UTC (permalink / raw)
  To: gcc-patches

Tested on x86_64-darwin21 and i686-darwin9, pushed to trunk, thanks,
Iain

--- 8< ---

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.
---
 gcc/config/darwin-sections.def | 2 +-
 gcc/config/darwin.cc           | 1 +
 gcc/config/darwin.h            | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/gcc/config/darwin-sections.def b/gcc/config/darwin-sections.def
index 62a51b9761c..de2334f4a7a 100644
--- a/gcc/config/darwin-sections.def
+++ b/gcc/config/darwin-sections.def
@@ -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)
diff --git a/gcc/config/darwin.cc b/gcc/config/darwin.cc
index 0d53e97ae80..b435bb2b80a 100644
--- a/gcc/config/darwin.cc
+++ b/gcc/config/darwin.cc
@@ -2271,6 +2271,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);
diff --git a/gcc/config/darwin.h b/gcc/config/darwin.h
index 1b3f1bd984c..b7cfab607db 100644
--- a/gcc/config/darwin.h
+++ b/gcc/config/darwin.h
@@ -1089,7 +1089,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)
 
-- 
2.39.2 (Apple Git-143)


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-09-04 10:58 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-04 10:57 [pushed] Darwin: Match system sections and relocs for exception tables Iain Sandoe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).