diff options
author | Richard Henderson <rth@twiddle.net> | 2016-02-09 13:12:33 +1100 |
---|---|---|
committer | Richard Henderson <rth@twiddle.net> | 2016-02-09 21:27:17 +1100 |
commit | 072dce81771f971f49f2480630842a2874a2c860 (patch) | |
tree | 6bfa97deb7d73078746b85a884fc9b89e5f8a026 | |
parent | 447f711575e70c09fd883f28d86e175993025277 (diff) | |
download | glibc-072dce81771f971f49f2480630842a2874a2c860.tar.gz |
i386: Implement execl{,e,p} without double stack allocation
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/execl.S | 39 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/execle.S | 46 | ||||
-rw-r--r-- | sysdeps/unix/sysv/linux/i386/execlp.S | 4 |
3 files changed, 89 insertions, 0 deletions
diff --git a/sysdeps/unix/sysv/linux/i386/execl.S b/sysdeps/unix/sysv/linux/i386/execl.S new file mode 100644 index 0000000000..047ef48a79 --- /dev/null +++ b/sysdeps/unix/sysv/linux/i386/execl.S @@ -0,0 +1,39 @@ +/* Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <sysdep.h> + +ENTRY(execl) + mov 4(%esp), %edx + lea 8(%esp), %eax + + push %eax /* alignment padding */ + cfi_adjust_cfa_offset(4) + push %eax /* create argv argument */ + cfi_adjust_cfa_offset(4) + push %edx /* create path argument */ + cfi_adjust_cfa_offset(4) + + /* Let execv deal with pic vs non-pic loading of __environ. */ + call HIDDEN_JUMPTARGET (execv) + + add $12, %esp + cfi_adjust_cfa_offset(-12) + ret +END(execl) + +libc_hidden_def (execl) diff --git a/sysdeps/unix/sysv/linux/i386/execle.S b/sysdeps/unix/sysv/linux/i386/execle.S new file mode 100644 index 0000000000..34cc7bc82a --- /dev/null +++ b/sysdeps/unix/sysv/linux/i386/execle.S @@ -0,0 +1,46 @@ +/* Copyright (C) 2016 Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, see + <http://www.gnu.org/licenses/>. */ + +#include <sysdep.h> + +ENTRY(execle) + lea 8(%esp), %eax /* find argv array */ + + /* Find the env argument. It is the array element after the argv + NULL terminator, which cannot be located before argv[1]. */ + mov 4(%eax), %edx + xor %ecx, %ecx +1: inc %ecx + test %edx, %edx + mov 4(%eax, %ecx, 4), %edx + jnz 1b + + push %edx /* create env argument */ + cfi_adjust_cfa_offset(4) + push %eax /* create argv argument */ + cfi_adjust_cfa_offset(4) + push 12(%esp) /* copy path argument */ + cfi_adjust_cfa_offset(4) + + call HIDDEN_JUMPTARGET (execve) + + add $12, %esp + cfi_adjust_cfa_offset(-12) + ret +END(execle) + +libc_hidden_def (execle) diff --git a/sysdeps/unix/sysv/linux/i386/execlp.S b/sysdeps/unix/sysv/linux/i386/execlp.S new file mode 100644 index 0000000000..d1c8806ff1 --- /dev/null +++ b/sysdeps/unix/sysv/linux/i386/execlp.S @@ -0,0 +1,4 @@ +#define execl execlp +#define execv execvp +#define __GI_execv __GI_execvp +#include "execl.S" |