[gcc/devel/omp/gcc-9] [Darwin] The need for FDE symbols is dependent on linker used, not OS rev.

Tobias Burnus burnus@gcc.gnu.org
Thu Mar 5 14:19:00 GMT 2020


https://gcc.gnu.org/g:3e57fa74b1ee2505da2e37fce2660e02e88d4c3d

commit 3e57fa74b1ee2505da2e37fce2660e02e88d4c3d
Author: Iain Sandoe <iain@sandoe.co.uk>
Date:   Wed Oct 30 20:05:32 2019 +0000

    [Darwin] The need for FDE symbols is dependent on linker used, not OS rev.
    
    For very old toolchains, the compiler generated extra symbols that mark the
    start of each FDE.  We no longer need this (since xcode 3 era) - so, for
    compatibility with newer linkers, omit this when it is not required.
    
    Since we have detection of the linker version, we can use that directly to
    determine if support is needed.
    
    2019-10-30  Iain Sandoe  <iain@sandoe.co.uk>
    
    	Backport from mainline
    	2019-06-18  Iain Sandoe  <iain@sandoe.co.uk>
    
    	* config/darwin.c (darwin_emit_unwind_label): New default to false.
    	(darwin_override_options): Set darwin_emit_unwind_label as needed.
    
    From-SVN: r277640

Diff:
---
 gcc/ChangeLog       |  8 ++++++++
 gcc/config/darwin.c | 37 +++++++++++++++++++++++++++----------
 2 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 648034e..5178bd6 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,6 +1,14 @@
 2019-10-30  Iain Sandoe  <iain@sandoe.co.uk>
 
 	Backport from mainline
+	2019-06-18  Iain Sandoe  <iain@sandoe.co.uk>
+
+	* config/darwin.c (darwin_emit_unwind_label): New.
+	(darwin_override_options): Set darwin_emit_unwind_label as needed.
+
+2019-10-30  Iain Sandoe  <iain@sandoe.co.uk>
+
+	Backport from mainline
 	2019-08-13 Iain Sandoe <iain@sandoe.co.uk>
 
 	* config/darwin.c (machopic_indirect_call_target): Rename symbol stub
diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index 597f3c6..59f3e2c 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -99,6 +99,10 @@ int generating_for_darwin_version ;
    for weak or single-definition items.  */
 static bool ld_uses_coal_sects = false;
 
+/* Very old (ld_classic) linkers need a symbol to mark the start of
+   each FDE.  */
+static bool ld_needs_eh_markers = false;
+
 /* Section names.  */
 section * darwin_sections[NUM_DARWIN_SECTIONS];
 
@@ -2164,11 +2168,11 @@ darwin_emit_unwind_label (FILE *file, tree decl, int for_eh, int empty)
   static int invok_count = 0;
   static tree last_fun_decl = NULL_TREE;
   
-  /* We use the linker to emit the .eh labels for Darwin 9 and above.  */
-  if (! for_eh || generating_for_darwin_version >= 9)
+  /* Modern linkers can produce distinct FDEs without compiler support.  */
+  if (! for_eh || ! ld_needs_eh_markers)
     return;
 
-  /* FIXME: This only works when the eh for all sections of a function is 
+  /* FIXME: This only works when the eh for all sections of a function are
      emitted at the same time.  If that changes, we would need to use a lookup
      table of some form to determine what to do.  Also, we should emit the
      unadorned label for the partition containing the public label for a
@@ -3343,21 +3347,34 @@ darwin_override_options (void)
      indirections and we no longer need to emit pic symbol stubs.
      However, if we are generating code for earlier ones (or for use in the
      kernel) the stubs might still be required, and this will be set true.
-     If the user sets it on or off - then that takes precedence. */
+     If the user sets it on or off - then that takes precedence.
+
+     Linkers that don't need stubs, don't need the EH symbol markers either.
+  */
 
   if (!global_options_set.x_darwin_symbol_stubs)
     {
-      if (darwin_target_linker) {
-	if (strverscmp (darwin_target_linker, MIN_LD64_OMIT_STUBS) < 0)
+      if (darwin_target_linker)
+	{
+	  if (strverscmp (darwin_target_linker, MIN_LD64_OMIT_STUBS) < 0)
+	    {
+	      darwin_symbol_stubs = true;
+	      ld_needs_eh_markers = true;
+	    }
+	}
+      else if (generating_for_darwin_version < 9)
+	{
+	  /* If we don't know the linker version and we're targeting an old
+	     system, we know no better than to assume the use of an earlier
+	     linker.  */
 	  darwin_symbol_stubs = true;
-      } else if (generating_for_darwin_version < 9)
-	/* We know no better than to assume the use of an earlier linker.  */
-	darwin_symbol_stubs = true;
+	  ld_needs_eh_markers = true;
+	}
     }
   else if (DARWIN_X86 && darwin_symbol_stubs && TARGET_64BIT)
     {
       inform (input_location,
-	      "%<-mpic-symbol-stubs%> is not required for 64b code (ignored)");
+	      "%<-msymbol-stubs%> is not required for 64b code (ignored)");
       darwin_symbol_stubs = false;
     }



More information about the Gcc-cvs mailing list