From: Richard Henderson Date: Tue, 9 Feb 2016 02:12:33 +0000 (+1100) Subject: i386: Implement execl{,e,p} without double stack allocation X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=072dce81771f971f49f2480630842a2874a2c860;p=thirdparty%2Fglibc.git i386: Implement execl{,e,p} without double stack allocation --- diff --git a/sysdeps/unix/sysv/linux/i386/execl.S b/sysdeps/unix/sysv/linux/i386/execl.S new file mode 100644 index 00000000000..047ef48a790 --- /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 + . */ + +#include + +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 00000000000..34cc7bc82a0 --- /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 + . */ + +#include + +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 00000000000..d1c8806ff10 --- /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"