Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 145339
b: refs/heads/master
c: c3dc5be
h: refs/heads/master
i:
  145337: ae9c1fb
  145335: 63df548
v: v3
  • Loading branch information
Oskar Schirmer authored and Linus Torvalds committed May 29, 2009
1 parent 4e9982b commit ed43e97
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 24 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ba9447198bdd945666a9bac5e556632a7acb235d
refs/heads/master: c3dc5bec05a2ae03a72ef82e321d77fb549d951c
3 changes: 0 additions & 3 deletions trunk/arch/arm/include/asm/flat.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
#ifndef __ARM_FLAT_H__
#define __ARM_FLAT_H__

/* An odd number of words will be pushed after this alignment, so
deliberately misalign the value. */
#define flat_stack_align(sp) sp = (void *)(((unsigned long)(sp) - 4) | 4)
#define flat_argvp_envp_on_stack() 1
#define flat_old_ram_flag(flags) (flags)
#define flat_reloc_valid(reloc, size) ((reloc) <= (size))
Expand Down
1 change: 0 additions & 1 deletion trunk/arch/blackfin/include/asm/flat.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

#include <asm/unaligned.h>

#define flat_stack_align(sp) /* nothing needed */
#define flat_argvp_envp_on_stack() 0
#define flat_old_ram_flag(flags) (flags)

Expand Down
1 change: 0 additions & 1 deletion trunk/arch/h8300/include/asm/flat.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#ifndef __H8300_FLAT_H__
#define __H8300_FLAT_H__

#define flat_stack_align(sp) /* nothing needed */
#define flat_argvp_envp_on_stack() 1
#define flat_old_ram_flag(flags) 1
#define flat_reloc_valid(reloc, size) ((reloc) <= (size))
Expand Down
1 change: 0 additions & 1 deletion trunk/arch/m32r/include/asm/flat.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#ifndef __ASM_M32R_FLAT_H
#define __ASM_M32R_FLAT_H

#define flat_stack_align(sp) (*sp += (*sp & 3 ? (4 - (*sp & 3)): 0))
#define flat_argvp_envp_on_stack() 0
#define flat_old_ram_flag(flags) (flags)
#define flat_set_persistent(relval, p) 0
Expand Down
1 change: 0 additions & 1 deletion trunk/arch/m68k/include/asm/flat.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#ifndef __M68KNOMMU_FLAT_H__
#define __M68KNOMMU_FLAT_H__

#define flat_stack_align(sp) /* nothing needed */
#define flat_argvp_envp_on_stack() 1
#define flat_old_ram_flag(flags) (flags)
#define flat_reloc_valid(reloc, size) ((reloc) <= (size))
Expand Down
1 change: 0 additions & 1 deletion trunk/arch/sh/include/asm/flat.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#ifndef __ASM_SH_FLAT_H
#define __ASM_SH_FLAT_H

#define flat_stack_align(sp) /* nothing needed */
#define flat_argvp_envp_on_stack() 0
#define flat_old_ram_flag(flags) (flags)
#define flat_reloc_valid(reloc, size) ((reloc) <= (size))
Expand Down
46 changes: 31 additions & 15 deletions trunk/fs/binfmt_flat.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
#include <asm/uaccess.h>
#include <asm/unaligned.h>
#include <asm/cacheflush.h>
#include <asm/page.h>

/****************************************************************************/

Expand All @@ -54,6 +55,18 @@
#define DBG_FLT(a...)
#endif

/*
* User data (stack, data section and bss) needs to be aligned
* for the same reasons as SLAB memory is, and to the same amount.
* Avoid duplicating architecture specific code by using the same
* macro as with SLAB allocation:
*/
#ifdef ARCH_SLAB_MINALIGN
#define FLAT_DATA_ALIGN (ARCH_SLAB_MINALIGN)
#else
#define FLAT_DATA_ALIGN (sizeof(void *))
#endif

#define RELOC_FAILED 0xff00ff01 /* Relocation incorrect somewhere */
#define UNLOADED_LIB 0x7ff000ff /* Placeholder for unused library */

Expand Down Expand Up @@ -114,20 +127,18 @@ static unsigned long create_flat_tables(
int envc = bprm->envc;
char uninitialized_var(dummy);

sp = (unsigned long *) ((-(unsigned long)sizeof(char *))&(unsigned long) p);
sp = (unsigned long *)p;
sp -= (envc + argc + 2) + 1 + (flat_argvp_envp_on_stack() ? 2 : 0);
sp = (unsigned long *) ((unsigned long)sp & -FLAT_DATA_ALIGN);
argv = sp + 1 + (flat_argvp_envp_on_stack() ? 2 : 0);
envp = argv + (argc + 1);

sp -= envc+1;
envp = sp;
sp -= argc+1;
argv = sp;

flat_stack_align(sp);
if (flat_argvp_envp_on_stack()) {
--sp; put_user((unsigned long) envp, sp);
--sp; put_user((unsigned long) argv, sp);
put_user((unsigned long) envp, sp + 2);
put_user((unsigned long) argv, sp + 1);
}

put_user(argc,--sp);
put_user(argc, sp);
current->mm->arg_start = (unsigned long) p;
while (argc-->0) {
put_user((unsigned long) p, argv++);
Expand Down Expand Up @@ -558,7 +569,9 @@ static int load_flat_file(struct linux_binprm * bprm,
ret = realdatastart;
goto err;
}
datapos = realdatastart + MAX_SHARED_LIBS * sizeof(unsigned long);
datapos = ALIGN(realdatastart +
MAX_SHARED_LIBS * sizeof(unsigned long),
FLAT_DATA_ALIGN);

DBG_FLT("BINFMT_FLAT: Allocated data+bss+stack (%d bytes): %x\n",
(int)(data_len + bss_len + stack_len), (int)datapos);
Expand Down Expand Up @@ -604,9 +617,12 @@ static int load_flat_file(struct linux_binprm * bprm,
}

realdatastart = textpos + ntohl(hdr->data_start);
datapos = realdatastart + MAX_SHARED_LIBS * sizeof(unsigned long);
reloc = (unsigned long *) (textpos + ntohl(hdr->reloc_start) +
MAX_SHARED_LIBS * sizeof(unsigned long));
datapos = ALIGN(realdatastart +
MAX_SHARED_LIBS * sizeof(unsigned long),
FLAT_DATA_ALIGN);

reloc = (unsigned long *)
(datapos + (ntohl(hdr->reloc_start) - text_len));
memp = textpos;
memp_size = len;
#ifdef CONFIG_BINFMT_ZFLAT
Expand Down Expand Up @@ -854,7 +870,7 @@ static int load_flat_binary(struct linux_binprm * bprm, struct pt_regs * regs)
stack_len = TOP_OF_ARGS - bprm->p; /* the strings */
stack_len += (bprm->argc + 1) * sizeof(char *); /* the argv array */
stack_len += (bprm->envc + 1) * sizeof(char *); /* the envp array */

stack_len += FLAT_DATA_ALIGN - 1; /* reserve for upcoming alignment */

res = load_flat_file(bprm, &libinfo, 0, &stack_len);
if (res > (unsigned long)-4096)
Expand Down

0 comments on commit ed43e97

Please sign in to comment.