93dc2d
commit 4fb4e7e821e36180835bf88e363f9f13b5797e3a
93dc2d
Author: Florian Weimer <fweimer@redhat.com>
93dc2d
Date:   Sun Dec 5 13:50:17 2021 +0100
93dc2d
93dc2d
    csu: Always use __executable_start in gmon-start.c
93dc2d
    
93dc2d
    Current binutils defines __executable_start as the lowest text
93dc2d
    address, so using the entry point address as a fallback is no
93dc2d
    longer necessary.  As a result, overriding <entry.h> is only
93dc2d
    necessary if the entry point is not called _start.
93dc2d
    
93dc2d
    The previous approach to define __ASSEMBLY__ to suppress the
93dc2d
    declaration breaks if headers included by <entry.h> are not
93dc2d
    compatible with __ASSEMBLY__.  This happens with rseq integration
93dc2d
    because it is necessary to include kernel headers in more places.
93dc2d
    
93dc2d
    Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
93dc2d
93dc2d
diff --git a/csu/gmon-start.c b/csu/gmon-start.c
93dc2d
index 344606a676c188d4..260c7613e291a32d 100644
93dc2d
--- a/csu/gmon-start.c
93dc2d
+++ b/csu/gmon-start.c
93dc2d
@@ -38,32 +38,12 @@
93dc2d
 #include <stdlib.h>
93dc2d
 #include <unistd.h>
93dc2d
 #include <elf-initfini.h>
93dc2d
-#define __ASSEMBLY__
93dc2d
-#include <entry.h>
93dc2d
-
93dc2d
-/* Beginning and end of our code segment. We cannot declare them
93dc2d
-   as the external functions since we want the addresses of those
93dc2d
-   labels. Taking the address of a function may have different
93dc2d
-   meanings on different platforms. */
93dc2d
-#ifdef ENTRY_POINT_DECL
93dc2d
-ENTRY_POINT_DECL(extern)
93dc2d
-#else
93dc2d
-extern char ENTRY_POINT[];
93dc2d
-#endif
93dc2d
-extern char etext[];
93dc2d
 
93dc2d
 /* Use __executable_start as the lowest address to keep profiling records
93dc2d
    if it provided by the linker.  */
93dc2d
-extern const char executable_start[] asm ("__executable_start")
93dc2d
-  __attribute__ ((weak, visibility ("hidden")));
93dc2d
+extern const char __executable_start[] __attribute__ ((visibility ("hidden")));
93dc2d
 
93dc2d
-#ifndef TEXT_START
93dc2d
-# ifdef ENTRY_POINT_DECL
93dc2d
-#  define TEXT_START ENTRY_POINT
93dc2d
-# else
93dc2d
-#  define TEXT_START &ENTRY_POINT
93dc2d
-# endif
93dc2d
-#endif
93dc2d
+extern char etext[];
93dc2d
 
93dc2d
 #if !ELF_INITFINI
93dc2d
 /* Instead of defining __gmon_start__ globally in gcrt1.o, we make it
93dc2d
@@ -97,10 +77,7 @@ __gmon_start__ (void)
93dc2d
   called = 1;
93dc2d
 
93dc2d
   /* Start keeping profiling records.  */
93dc2d
-  if (&executable_start != NULL)
93dc2d
-    __monstartup ((u_long) &executable_start, (u_long) &etext);
93dc2d
-  else
93dc2d
-    __monstartup ((u_long) TEXT_START, (u_long) &etext);
93dc2d
+  __monstartup ((u_long) &__executable_start, (u_long) &etext);
93dc2d
 
93dc2d
   /* Call _mcleanup before exiting; it will write out gmon.out from the
93dc2d
      collected data.  */
93dc2d
diff --git a/sysdeps/hppa/entry.h b/sysdeps/hppa/entry.h
93dc2d
deleted file mode 100644
93dc2d
index 5ea5b47448ceb2e7..0000000000000000
93dc2d
--- a/sysdeps/hppa/entry.h
93dc2d
+++ /dev/null
93dc2d
@@ -1,13 +0,0 @@
93dc2d
-#ifndef __ASSEMBLY__
93dc2d
-extern void _start (void);
93dc2d
-#endif
93dc2d
-
93dc2d
-/* Lives in libgcc.so and canonicalizes function pointers for comparison.  */
93dc2d
-extern unsigned int __canonicalize_funcptr_for_compare (unsigned int fptr);
93dc2d
-
93dc2d
-/* The function's entry point is stored in the first word of the
93dc2d
-   function descriptor (plabel) of _start().  */
93dc2d
-#define ENTRY_POINT __canonicalize_funcptr_for_compare((unsigned int)_start)
93dc2d
-
93dc2d
-/* We have to provide a special declaration.  */
93dc2d
-#define ENTRY_POINT_DECL(class) class void _start (void);
93dc2d
diff --git a/sysdeps/ia64/entry.h b/sysdeps/ia64/entry.h
93dc2d
deleted file mode 100644
93dc2d
index e11b49fc53602eb8..0000000000000000
93dc2d
--- a/sysdeps/ia64/entry.h
93dc2d
+++ /dev/null
93dc2d
@@ -1,13 +0,0 @@
93dc2d
-#include <link.h>
93dc2d
-#include <dl-fptr.h>
93dc2d
-
93dc2d
-#ifndef __ASSEMBLY__
93dc2d
-extern void _start (void);
93dc2d
-#endif
93dc2d
-
93dc2d
-/* The function's entry point is stored in the first word of the
93dc2d
-   function descriptor (plabel) of _start().  */
93dc2d
-#define ENTRY_POINT ELF_PTR_TO_FDESC (_start)->ip
93dc2d
-
93dc2d
-/* We have to provide a special declaration.  */
93dc2d
-#define ENTRY_POINT_DECL(class) class void _start (void);
93dc2d
diff --git a/sysdeps/powerpc/powerpc64/entry.h b/sysdeps/powerpc/powerpc64/entry.h
93dc2d
deleted file mode 100644
93dc2d
index 99c81cb9820d188d..0000000000000000
93dc2d
--- a/sysdeps/powerpc/powerpc64/entry.h
93dc2d
+++ /dev/null
93dc2d
@@ -1,37 +0,0 @@
93dc2d
-/* Finding the entry point and start of text.  PowerPC64 version.
93dc2d
-   Copyright (C) 2002-2021 Free Software Foundation, Inc.
93dc2d
-   This file is part of the GNU C Library.
93dc2d
-
93dc2d
-   The GNU C Library is free software; you can redistribute it and/or
93dc2d
-   modify it under the terms of the GNU Lesser General Public
93dc2d
-   License as published by the Free Software Foundation; either
93dc2d
-   version 2.1 of the License, or (at your option) any later version.
93dc2d
-
93dc2d
-   The GNU C Library is distributed in the hope that it will be useful,
93dc2d
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
93dc2d
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
93dc2d
-   Lesser General Public License for more details.
93dc2d
-
93dc2d
-   You should have received a copy of the GNU Lesser General Public
93dc2d
-   License along with the GNU C Library; if not, see
93dc2d
-   <https://www.gnu.org/licenses/>.  */
93dc2d
-
93dc2d
-
93dc2d
-#ifndef __ASSEMBLY__
93dc2d
-extern void _start (void);
93dc2d
-#endif
93dc2d
-
93dc2d
-#define ENTRY_POINT _start
93dc2d
-
93dc2d
-#if _CALL_ELF != 2
93dc2d
-/* We have to provide a special declaration.  */
93dc2d
-#define ENTRY_POINT_DECL(class) class void _start (void);
93dc2d
-
93dc2d
-/* Use the address of ._start as the lowest address for which we need
93dc2d
-   to keep profiling records.  We can't copy the ia64 scheme as our
93dc2d
-   entry poiny address is really the address of the function
93dc2d
-   descriptor, not the actual function entry.  */
93dc2d
-#define TEXT_START \
93dc2d
-  ({ extern unsigned long int _start_as_data[] asm ("_start");  \
93dc2d
-     _start_as_data[0]; })
93dc2d
-#endif