about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2021-01-06 14:28:02 +0000
committerSzabolcs Nagy <szabolcs.nagy@arm.com>2021-01-20 14:42:46 +0000
commit4da71cb981057048e8cf9dec8731ad936b433e38 (patch)
tree5c1e3843d2a5093ac69b6d3f1dd3c89b47b5cd8f
parent51119c6aa5f2a7ff0966d5c9fda4a61d781591fb (diff)
downloadglibc-4da71cb981057048e8cf9dec8731ad936b433e38.tar.gz
glibc-4da71cb981057048e8cf9dec8731ad936b433e38.tar.xz
glibc-4da71cb981057048e8cf9dec8731ad936b433e38.zip
csu: Avoid weak ref for __ehdr_start in static PIE
All linkers support __ehdr_start that support static PIE linking,
so there is no need to check for its presence via a weak reference.

This avoids a RELATIVE relocation in static PIE startup code on some
targets.

With non-PIE static linking the weak ref check is kept in case the
linker does not support __ehdr_start.
-rw-r--r--csu/libc-start.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/csu/libc-start.c b/csu/libc-start.c
index db859c3bed..5b9ce1d158 100644
--- a/csu/libc-start.c
+++ b/csu/libc-start.c
@@ -175,8 +175,12 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL),
          information from auxv.  */
 
       extern const ElfW(Ehdr) __ehdr_start
+# if BUILD_PIE_DEFAULT
+	__attribute__ ((visibility ("hidden")));
+# else
 	__attribute__ ((weak, visibility ("hidden")));
       if (&__ehdr_start != NULL)
+# endif
         {
           assert (__ehdr_start.e_phentsize == sizeof *GL(dl_phdr));
           GL(dl_phdr) = (const void *) &__ehdr_start + __ehdr_start.e_phoff;