]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
i386: Implement execl{,e,p} without double stack allocation
authorRichard Henderson <rth@twiddle.net>
Tue, 9 Feb 2016 02:12:33 +0000 (13:12 +1100)
committerRichard Henderson <rth@twiddle.net>
Tue, 9 Feb 2016 10:27:17 +0000 (21:27 +1100)
sysdeps/unix/sysv/linux/i386/execl.S [new file with mode: 0644]
sysdeps/unix/sysv/linux/i386/execle.S [new file with mode: 0644]
sysdeps/unix/sysv/linux/i386/execlp.S [new file with mode: 0644]

diff --git a/sysdeps/unix/sysv/linux/i386/execl.S b/sysdeps/unix/sysv/linux/i386/execl.S
new file mode 100644 (file)
index 0000000..047ef48
--- /dev/null
@@ -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 (file)
index 0000000..34cc7bc
--- /dev/null
@@ -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 (file)
index 0000000..d1c8806
--- /dev/null
@@ -0,0 +1,4 @@
+#define execl          execlp
+#define execv          execvp
+#define __GI_execv     __GI_execvp
+#include "execl.S"