[Darwin,machopic,10/n] Rework X86 mcount stub code.
diff mbox series

Message ID 318C2703-4572-43B2-A49B-137A1F9AE89B@sandoe.co.uk
State New
Headers show
Series
  • [Darwin,machopic,10/n] Rework X86 mcount stub code.
Related show

Commit Message

Iain Sandoe Nov. 9, 2019, 1:49 p.m. UTC
More machopic cleanups…

When a stub is used to call the mcount function, the code is already
marking it as used unconditionally;  This is the only use of the so-
called validation outside darwin.{h,c}.  This moves the 'validation'
into darwin.c which is a step towards making validation routine local.

tested on x86_64-darwin16 (m32/m64)
applied to mainline,
thanks
Iain

gcc/

2019-11-09  Iain Sandoe  <iain@sandoe.co.uk>

	* config/darwin.c (machopic_mcount_stub_name): Validate the
	symbol stub name when it is created.
	* config/i386/darwin.h (FUNCTION_PROFILER): Remove the symbol
	stub validation.

Patch
diff mbox series

diff --git a/gcc/config/darwin.c b/gcc/config/darwin.c
index c0fafed..f34be22 100644
--- a/gcc/config/darwin.c
+++ b/gcc/config/darwin.c
@@ -601,15 +601,6 @@  machopic_indirection_name (rtx sym_ref, bool stub_p)
   return p->ptr_name;
 }
 
-/* Return the name of the stub for the mcount function.  */
-
-const char*
-machopic_mcount_stub_name (void)
-{
-  rtx symbol = gen_rtx_SYMBOL_REF (Pmode, "*mcount");
-  return machopic_indirection_name (symbol, /*stub_p=*/true);
-}
-
 /* If NAME is the name of a stub or a non-lazy pointer , mark the stub
    or non-lazy pointer as used -- and mark the object to which the
    pointer/stub refers as used as well, since the pointer/stub will
@@ -2155,6 +2146,20 @@  darwin_emit_except_table_label (FILE *file)
 			       except_table_label_num++);
   ASM_OUTPUT_LABEL (file, section_start_label);
 }
+
+/* Return, and mark as used, the name of the stub for the mcount function.
+   Currently, this is only called by X86 code in the expansion of the
+   FUNCTION_PROFILER macro, when stubs are enabled.  */
+
+const char*
+machopic_mcount_stub_name (void)
+{
+  rtx symbol = gen_rtx_SYMBOL_REF (Pmode, "*mcount");
+  const char *name = machopic_indirection_name (symbol, /*stub_p=*/true);
+  machopic_validate_stub_or_non_lazy_ptr (name);
+  return name;
+}
+
 /* Generate a PC-relative reference to a Mach-O non-lazy-symbol.  */
 
 void
diff --git a/gcc/config/i386/darwin.h b/gcc/config/i386/darwin.h
index bdb36f0..d1e53ef 100644
--- a/gcc/config/i386/darwin.h
+++ b/gcc/config/i386/darwin.h
@@ -239,7 +239,8 @@  along with GCC; see the file COPYING3.  If not see
 #undef TARGET_ASM_OUTPUT_IDENT
 #define TARGET_ASM_OUTPUT_IDENT default_asm_output_ident_directive
 
-/* Darwin profiling -- call mcount.  */
+/* Darwin profiling -- call mcount.
+   If we need a stub, then we unconditionally mark it as used.  */
 #undef FUNCTION_PROFILER
 #define FUNCTION_PROFILER(FILE, LABELNO)				\
   do {									\
@@ -248,7 +249,6 @@  along with GCC; see the file COPYING3.  If not see
       {									\
 	const char *name = machopic_mcount_stub_name ();		\
 	fprintf (FILE, "\tcall %s\n", name+1);  /*  skip '&'  */	\
-	machopic_validate_stub_or_non_lazy_ptr (name);			\
       }									\
     else fprintf (FILE, "\tcall mcount\n");				\
   } while (0)