[parisc-linux-cvs] linux deller
Helge Deller
deller@gmx.de
Sun, 11 Nov 2001 16:21:15 +0100
--------------Boundary-00=_FN6NGPFJ09AXH5MTELEJ
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 8bit
On Sunday 11 November 2001 16:20, Helge Deller wrote:
> CVSROOT: /var/cvs
> Module name: linux
> Changes by: deller 01/11/11 08:20:21
>
> Modified files:
> fs : exec.c
>
> Log message:
> it seems this "#ifdef ARCH_STACK_GROWSUP" hack got lost during the
> merge.... willy: Is this correct ?
--------------Boundary-00=_FN6NGPFJ09AXH5MTELEJ
Content-Type: text/plain;
charset="iso-8859-1";
name="t2"
Content-Transfer-Encoding: 8bit
Content-Disposition: attachment; filename="t2"
Index: exec.c
===================================================================
RCS file: /var/cvs/linux/fs/exec.c,v
retrieving revision 1.27
diff -u -p -r1.27 exec.c
--- exec.c 2001/11/09 23:36:44 1.27
+++ exec.c 2001/11/11 15:18:25
@@ -297,7 +297,46 @@ int setup_arg_pages(struct linux_binprm
struct vm_area_struct *mpnt;
int i;
+#ifdef ARCH_STACK_GROWSUP
+ /* Move the argument and environment strings to the bottom of the
+ * stack space.
+ */
+ int offset, j;
+ char *to, *from;
+
+ /* Start by shifting all the pages down */
+ i = 0;
+ for (j = 0; j < MAX_ARG_PAGES; j++) {
+ struct page *page = bprm->page[j];
+ if (!page)
+ continue;
+ bprm->page[i++] = page;
+ }
+ /* Now move them within their pages */
+ offset = bprm->p % PAGE_SIZE;
+ to = kmap(bprm->page[0]);
+ for (j = 1; j < i; j++) {
+ memmove(to, to + offset, PAGE_SIZE - offset);
+ from = kmap(bprm->page[j]);
+ memcpy(to + PAGE_SIZE - offset, from, offset);
+ kunmap(bprm[j - 1]);
+ to = from;
+ }
+ memmove(to, to + offset, PAGE_SIZE - offset);
+ kunmap(bprm[j - 1]);
+
+ /* Adjust bprm->p to point to the end of the strings. */
+ bprm->p = PAGE_SIZE * i - offset;
+ stack_base = STACK_TOP - current->rlim[RLIMIT_STACK].rlim_max;
+ current->mm->arg_start = stack_base;
+
+ /* zero pages that were copied above */
+ while (i < MAX_ARG_PAGES)
+ bprm->page[i++] = NULL;
+#else
stack_base = STACK_TOP - MAX_ARG_PAGES*PAGE_SIZE;
+ current->mm->arg_start = bprm->p + stack_base;
+#endif
bprm->p += stack_base;
if (bprm->loader)
@@ -311,8 +350,14 @@ int setup_arg_pages(struct linux_binprm
down_write(¤t->mm->mmap_sem);
{
mpnt->vm_mm = current->mm;
+#ifdef ARCH_STACK_GROWSUP
+ mpnt->vm_start = stack_base;
+ mpnt->vm_end = PAGE_MASK &
+ (PAGE_SIZE - 1 + (unsigned long) bprm->p);
+#else
mpnt->vm_start = PAGE_MASK & (unsigned long) bprm->p;
mpnt->vm_end = STACK_TOP;
+#endif
mpnt->vm_page_prot = PAGE_COPY;
mpnt->vm_flags = VM_STACK_FLAGS;
mpnt->vm_ops = NULL;
--------------Boundary-00=_FN6NGPFJ09AXH5MTELEJ--