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