X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=fs%2Fbinfmt_elf.c;h=a93b1170551b547b41a5ed2d779a5c44f1884dcd;hb=91dbbe4896f374462c5912fbb3ec0dbab4814783;hp=4628c42ca892ef9248dc7a6dc0f1ed2134211de6;hpb=256ae6a720618cbbfacc5e62ea1fe7c129d1b644;p=linux-2.6 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 4628c42ca8..a93b117055 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -513,6 +513,7 @@ out: return error; } +#ifdef CONFIG_ARCH_SUPPORTS_AOUT static unsigned long load_aout_interp(struct exec *interp_ex, struct file *interpreter) { @@ -558,6 +559,14 @@ static unsigned long load_aout_interp(struct exec *interp_ex, out: return elf_entry; } +#else +/* dummy extern - the function should never be called if !CONFIG_AOUT_BINFMT */ +static inline unsigned long load_aout_interp(struct exec *interp_ex, + struct file *interpreter) +{ + return -ELIBACC; +} +#endif /* * These are the functions used to load ELF style executables and shared @@ -565,9 +574,15 @@ out: */ #define INTERPRETER_NONE 0 -#define INTERPRETER_AOUT 1 #define INTERPRETER_ELF 2 +#ifdef CONFIG_ARCH_SUPPORTS_AOUT +#define INTERPRETER_AOUT 1 +#define IS_AOUT_INTERP(x) ((x) == INTERPRETER_AOUT) +#else +#define IS_AOUT_INTERP(x) (0) +#endif + #ifndef STACK_RND_MASK #define STACK_RND_MASK (0x7ff >> (PAGE_SHIFT - 12)) /* 8MB of VA */ #endif @@ -775,6 +790,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) /* Some simple consistency checks for the interpreter */ if (elf_interpreter) { static int warn; +#ifdef CONFIG_ARCH_SUPPORTS_AOUT interpreter_type = INTERPRETER_ELF | INTERPRETER_AOUT; /* Now figure out which format our binary is */ @@ -782,11 +798,13 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) (N_MAGIC(loc->interp_ex) != ZMAGIC) && (N_MAGIC(loc->interp_ex) != QMAGIC)) interpreter_type = INTERPRETER_ELF; - +#else + interpreter_type = INTERPRETER_ELF; +#endif if (memcmp(loc->interp_elf_ex.e_ident, ELFMAG, SELFMAG) != 0) interpreter_type &= ~INTERPRETER_ELF; - if (interpreter_type == INTERPRETER_AOUT && warn < 10) { + if (IS_AOUT_INTERP(interpreter_type) && warn < 10) { printk(KERN_WARNING "a.out ELF interpreter %s is " "deprecated and will not be supported " "after Linux 2.6.25\n", elf_interpreter); @@ -815,7 +833,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) /* OK, we are done with that, now set up the arg stuff, and then start this sucker up */ - if ((!bprm->sh_bang) && (interpreter_type == INTERPRETER_AOUT)) { + if (IS_AOUT_INTERP(interpreter_type) && !bprm->sh_bang) { char *passed_p = passed_fileno; sprintf(passed_fileno, "%d", elf_exec_fileno); @@ -1004,7 +1022,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) } if (elf_interpreter) { - if (interpreter_type == INTERPRETER_AOUT) { + if (IS_AOUT_INTERP(interpreter_type)) { elf_entry = load_aout_interp(&loc->interp_ex, interpreter); } else { @@ -1045,7 +1063,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) kfree(elf_phdata); - if (interpreter_type != INTERPRETER_AOUT) + if (!IS_AOUT_INTERP(interpreter_type)) sys_close(elf_exec_fileno); set_binfmt(&elf_format); @@ -1061,14 +1079,14 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) compute_creds(bprm); current->flags &= ~PF_FORKNOEXEC; retval = create_elf_tables(bprm, &loc->elf_ex, - (interpreter_type == INTERPRETER_AOUT), + IS_AOUT_INTERP(interpreter_type), load_addr, interp_load_addr); if (retval < 0) { send_sig(SIGKILL, current, 0); goto out; } /* N.B. passed_fileno might not be initialized? */ - if (interpreter_type == INTERPRETER_AOUT) + if (IS_AOUT_INTERP(interpreter_type)) current->mm->arg_start += strlen(passed_fileno) + 1; current->mm->end_code = end_code; current->mm->start_code = start_code; @@ -1077,7 +1095,7 @@ static int load_elf_binary(struct linux_binprm *bprm, struct pt_regs *regs) current->mm->start_stack = bprm->p; #ifdef arch_randomize_brk - if (current->flags & PF_RANDOMIZE) + if ((current->flags & PF_RANDOMIZE) && (randomize_va_space > 1)) current->mm->brk = current->mm->start_brk = arch_randomize_brk(current->mm); #endif