Skip to content

Commit

Permalink
Replace @PLT with @GOTPCREL(%rip) in call
Browse files Browse the repository at this point in the history
Since __libc_start_main is called very early, lazy binding isn't relevant
here.  Use indirect branch via GOT to avoid extra branch to PLT slot.

	[BZ #19745]
	* sysdeps/x86_64/start.S (_start): __libc_start_main@PLT
	with *__libc_start_main@GOTPCREL(%rip) in call.
  • Loading branch information
H.J. Lu committed Mar 5, 2016
1 parent 684ce7e commit 21683b5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
2016-03-04 H.J. Lu <hongjiu.lu@intel.com>

[BZ #19745]
* sysdeps/x86_64/start.S (_start): Replace __libc_start_main@PLT
with *__libc_start_main@GOTPCREL(%rip) in call.

2016-03-04 Roland McGrath <roland@hack.frob.com>

* Makefile (tests-special): Add $(objpfx)c++-types-check.out only
Expand Down
6 changes: 4 additions & 2 deletions sysdeps/x86_64/start.S
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ ENTRY (_start)
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
But let the libc call main. Since __libc_start_main is
called very early, lazy binding isn't relevant here. Use
indirect branch via GOT to avoid extra branch to PLT slot. */
call *__libc_start_main@GOTPCREL(%rip)
#else
/* Pass address of our own entry points to .fini and .init. */
mov $__libc_csu_fini, %R8_LP
Expand Down

0 comments on commit 21683b5

Please sign in to comment.