This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
PATCH: Simulate popping 4byte argument count and use RXX_LP
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: GNU C Library <libc-alpha at sourceware dot org>
- Date: Mon, 19 Mar 2012 13:38:50 -0700
- Subject: PATCH: Simulate popping 4byte argument count and use RXX_LP
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
Hi,
This patch simulates popping 4byte argument count and uses RXX_LP.
This is another example to use RXX_LP.
H.J.
---
2012-03-19 H.J. Lu <hongjiu.lu@intel.com>
* sysdeps/x86_64/elf/start.S: Include <sysdep.h>. Simulate
popping 4byte argument count for x32. Use RXX_LP.
diff --git a/sysdeps/x86_64/elf/start.S b/sysdeps/x86_64/elf/start.S
index 68d61e2..3120365 100644
--- a/sysdeps/x86_64/elf/start.S
+++ b/sysdeps/x86_64/elf/start.S
@@ -44,15 +44,16 @@
before this code runs.
%rsp The stack contains the arguments and environment:
- 0(%rsp) argc
- 8(%rsp) argv[0]
+ 0(%rsp) argc
+ LP_SIZE(%rsp) argv[0]
...
- (8*argc)(%rsp) NULL
- (8*(argc+1))(%rsp) envp[0]
+ (LP_SIZE*argc)(%rsp) NULL
+ (LP_SIZE*(argc+1))(%rsp) envp[0]
...
- NULL
+ NULL
*/
+#include <sysdep.h>
#include "bp-sym.h"
.text
@@ -77,12 +78,17 @@ _start:
rtld_fini: %r9
stack_end: stack. */
- movq %rdx, %r9 /* Address of the shared library termination
+ mov %RDX_LP, %R9_LP /* Address of the shared library termination
function. */
+#ifdef __LP64__
popq %rsi /* Pop the argument count. */
- movq %rsp, %rdx /* argv starts just at the current stack top. */
+#else
+ mov (%rsp),%esi /* Simulate popping 4byte argument count. */
+ addl $4,%esp
+#endif
+ mov %RSP_LP, %RDX_LP /* argv starts just at the current stack top. */
/* Align the stack to a 16 byte boundary to follow the ABI. */
- andq $~15, %rsp
+ and $~15, %RSP_LP
pushq %rax /* Push garbage because we push 8 more bytes. */
@@ -92,20 +98,20 @@ _start:
#ifdef SHARED
/* Pass address of our own entry points to .fini and .init. */
- movq __libc_csu_fini@GOTPCREL(%rip), %r8
- movq __libc_csu_init@GOTPCREL(%rip), %rcx
+ mov __libc_csu_fini@GOTPCREL(%rip), %R8_LP
+ mov __libc_csu_init@GOTPCREL(%rip), %RCX_LP
- movq BP_SYM (main)@GOTPCREL(%rip), %rdi
+ mov BP_SYM (main)@GOTPCREL(%rip), %RDI_LP
/* Call the user's main function, and exit with its value.
But let the libc call main. */
call BP_SYM (__libc_start_main)@PLT
#else
/* Pass address of our own entry points to .fini and .init. */
- movq $__libc_csu_fini, %r8
- movq $__libc_csu_init, %rcx
+ mov $__libc_csu_fini, %R8_LP
+ mov $__libc_csu_init, %RCX_LP
- movq $BP_SYM (main), %rdi
+ mov $BP_SYM (main), %RDI_LP
/* Call the user's main function, and exit with its value.
But let the libc call main. */
--
1.7.6.5