summaryrefslogtreecommitdiff
path: root/sysdeps/x86_64/start.S
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2018-12-27 16:33:27 +0000
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2018-12-27 16:33:27 +0000
commit064374be911f72dfaec8a75f06da1f9fc1827712 (patch)
treead96fd1f1b9b57a50005db7803f6b79e748bb820 /sysdeps/x86_64/start.S
parent4dc1e6e42f1f602e1d2227e112f2db8dce9da763 (diff)
parent7c7d34a16f08f84427b3f617313d9633423ad5eb (diff)
Merge commit 'refs/top-bases/t/hurdsig-global-dispositions' into t/hurdsig-global-dispositions
Diffstat (limited to 'sysdeps/x86_64/start.S')
-rw-r--r--sysdeps/x86_64/start.S19
1 files changed, 10 insertions, 9 deletions
diff --git a/sysdeps/x86_64/start.S b/sysdeps/x86_64/start.S
index 1374974307..354d2e6ec7 100644
--- a/sysdeps/x86_64/start.S
+++ b/sysdeps/x86_64/start.S
@@ -1,5 +1,5 @@
/* Startup code compliant to the ELF x86-64 ABI.
- Copyright (C) 2001-2016 Free Software Foundation, Inc.
+ Copyright (C) 2001-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Andreas Jaeger <aj@suse.de>, 2001.
@@ -96,27 +96,28 @@ ENTRY (_start)
which grow downwards). */
pushq %rsp
-#ifdef SHARED
+#ifdef PIC
/* Pass address of our own entry points to .fini and .init. */
mov __libc_csu_fini@GOTPCREL(%rip), %R8_LP
mov __libc_csu_init@GOTPCREL(%rip), %RCX_LP
mov main@GOTPCREL(%rip), %RDI_LP
-
- /* Call the user's main function, and exit with its value.
- But let the libc call main. */
- call __libc_start_main@PLT
#else
/* Pass address of our own entry points to .fini and .init. */
mov $__libc_csu_fini, %R8_LP
mov $__libc_csu_init, %RCX_LP
mov $main, %RDI_LP
+#endif
/* Call the user's main function, and exit with its value.
- But let the libc call main. */
- call __libc_start_main
-#endif
+ But let the libc call main. Since __libc_start_main in
+ libc.so is called very early, lazy binding isn't relevant
+ here. Use indirect branch via GOT to avoid extra branch
+ to PLT slot. In case of static executable, ld in binutils
+ 2.26 or above can convert indirect branch into direct
+ branch. */
+ call *__libc_start_main@GOTPCREL(%rip)
hlt /* Crash if somehow `exit' does return. */
END (_start)