qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: qemu-devel@nongnu.org
Cc: paul@codesourcery.com
Subject: [Qemu-devel] [PATCH 10/12] linux-user: Remove partial support for a.out interpreters.
Date: Wed,  5 May 2010 11:07:46 -0700	[thread overview]
Message-ID: <1273082868-13675-11-git-send-email-rth@twiddle.net> (raw)
In-Reply-To: <cover.1270486025.git.rth@twiddle.net>

At the bottom of the a.out support was the unimplemented load_aout_interp
function.  There were other portions of the support that didn't look
right; when I went to look in the Linux kernel for clarification, I found
that the support for such interpreters has been removed from binfmt_elf.
There doesn't seem to be any reason to keep this broken support in qemu.

Signed-off-by: Richard Henderson <rth@twiddle.net>
---
 linux-user/elfload.c |   79 ++++++--------------------------------------------
 1 files changed, 9 insertions(+), 70 deletions(-)

diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index bd4b8fc..77267a4 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -819,10 +819,6 @@ struct exec
 #define TARGET_ELF_PAGESTART(_v) ((_v) & ~(unsigned long)(TARGET_ELF_EXEC_PAGESIZE-1))
 #define TARGET_ELF_PAGEOFFSET(_v) ((_v) & (TARGET_ELF_EXEC_PAGESIZE-1))
 
-#define INTERPRETER_NONE 0
-#define INTERPRETER_AOUT 1
-#define INTERPRETER_ELF 2
-
 #define DLINFO_ITEMS 12
 
 static inline void memcpy_fromfs(void * to, const void * from, unsigned long n)
@@ -830,8 +826,6 @@ static inline void memcpy_fromfs(void * to, const void * from, unsigned long n)
     memcpy(to, from, n);
 }
 
-static int load_aout_interp(void * exptr, int interp_fd);
-
 #ifdef BSWAP_NEEDED
 static void bswap_ehdr(struct elfhdr *ehdr)
 {
@@ -1069,7 +1063,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
                                    struct elfhdr * exec,
                                    abi_ulong load_addr,
                                    abi_ulong load_bias,
-                                   abi_ulong interp_load_addr, int ibcs,
+                                   abi_ulong interp_load_addr,
                                    struct image_info *info)
 {
     abi_ulong sp;
@@ -1099,7 +1093,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
     size += DLINFO_ARCH_ITEMS * 2;
 #endif
     size += envc + argc + 2;
-    size += (!ibcs ? 3 : 1);    /* argc itself */
+    size += 1;  /* argc itself */
     size *= n;
     if (size & 15)
         sp -= 16 - (size & 15);
@@ -1141,7 +1135,7 @@ static abi_ulong create_elf_tables(abi_ulong p, int argc, int envc,
 
     info->saved_auxv = sp;
 
-    sp = loader_build_argptr(envc, argc, sp, p, !ibcs);
+    sp = loader_build_argptr(envc, argc, sp, p, 0);
     return sp;
 }
 
@@ -1394,11 +1388,9 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
 {
     struct elfhdr elf_ex;
     struct elfhdr interp_elf_ex;
-    struct exec interp_ex;
     int interpreter_fd = -1; /* avoid warning */
     abi_ulong load_addr, load_bias;
     int load_addr_set = 0;
-    unsigned int interpreter_type = INTERPRETER_NONE;
     unsigned char ibcs2_interpreter;
     int i;
     abi_ulong mapped_addr;
@@ -1412,7 +1404,6 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
     abi_ulong start_code, end_code, start_data, end_data;
     abi_ulong reloc_func_desc = 0;
     abi_ulong elf_stack;
-    char passed_fileno[6];
 
     ibcs2_interpreter = 0;
     status = 0;
@@ -1462,7 +1453,6 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
     end_code = 0;
     start_data = 0;
     end_data = 0;
-    interp_ex.a_info = 0;
 
     elf_ppnt = elf_phdata;
     for(i=0;i < elf_ex.e_phnum; i++) {
@@ -1527,59 +1517,22 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
                 memset(bprm->buf, 0, BPRM_BUF_SIZE - retval);
             }
 
-            interp_ex = *((struct exec *) bprm->buf); /* aout exec-header */
-            interp_elf_ex = *((struct elfhdr *) bprm->buf); /* elf exec-header */
+            interp_elf_ex = *((struct elfhdr *) bprm->buf);
         }
         elf_ppnt++;
     }
 
     /* Some simple consistency checks for the interpreter */
-    if (elf_interpreter){
-        interpreter_type = INTERPRETER_ELF | INTERPRETER_AOUT;
-
-        /* Now figure out which format our binary is */
-        if ((N_MAGIC(interp_ex) != OMAGIC) && (N_MAGIC(interp_ex) != ZMAGIC) &&
-            (N_MAGIC(interp_ex) != QMAGIC)) {
-            interpreter_type = INTERPRETER_ELF;
-        }
-
+    if (elf_interpreter) {
         if (!elf_check_ident(&interp_elf_ex)) {
-            interpreter_type &= ~INTERPRETER_ELF;
-        }
-
-        if (!interpreter_type) {
             free(elf_interpreter);
             free(elf_phdata);
             close(bprm->fd);
+            close(interpreter_fd);
             return -ELIBBAD;
         }
     }
 
-    /* OK, we are done with that, now set up the arg stuff,
-       and then start this sucker up */
-
-    {
-        char * passed_p;
-
-        if (interpreter_type == INTERPRETER_AOUT) {
-            snprintf(passed_fileno, sizeof(passed_fileno), "%d", bprm->fd);
-            passed_p = passed_fileno;
-
-            if (elf_interpreter) {
-                bprm->p = copy_elf_strings(1,&passed_p,bprm->page,bprm->p);
-                bprm->argc++;
-            }
-        }
-        if (!bprm->p) {
-            if (elf_interpreter) {
-                free(elf_interpreter);
-            }
-            free (elf_phdata);
-            close(bprm->fd);
-            return -E2BIG;
-        }
-    }
-
     /* OK, This is the point of no return */
     info->end_data = 0;
     info->end_code = 0;
@@ -1772,15 +1725,9 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
     end_data += load_bias;
 
     if (elf_interpreter) {
-        if (interpreter_type & 1) {
-            elf_entry = load_aout_interp(&interp_ex, interpreter_fd);
-        } else if (interpreter_type & 2) {
-            elf_entry = load_elf_interp(&interp_elf_ex, interpreter_fd,
-                                        &interp_load_addr, bprm->buf);
-        }
+        elf_entry = load_elf_interp(&interp_elf_ex, interpreter_fd,
+                                    &interp_load_addr, bprm->buf);
         reloc_func_desc = interp_load_addr;
-
-        close(interpreter_fd);
         free(elf_interpreter);
 
         if (elf_entry == ~((abi_ulong)0UL)) {
@@ -1797,7 +1744,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
         load_symbols(&elf_ex, bprm->fd, load_bias);
     }
 
-    if (interpreter_type != INTERPRETER_AOUT) close(bprm->fd);
+    close(bprm->fd);
     info->personality = (ibcs2_interpreter ? PER_SVR4 : PER_LINUX);
 
 #ifdef LOW_ELF_STACK
@@ -1809,7 +1756,6 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
                                 &elf_ex,
                                 load_addr, load_bias,
                                 interp_load_addr,
-                                (interpreter_type == INTERPRETER_AOUT ? 0 : 1),
                                 info);
     info->load_addr = reloc_func_desc;
     info->start_brk = info->brk = elf_brk;
@@ -2692,15 +2638,8 @@ static int elf_core_dump(int signr, const CPUState *env)
         return (-errno);
     return (0);
 }
-
 #endif /* USE_ELF_CORE_DUMP */
 
-static int load_aout_interp(void * exptr, int interp_fd)
-{
-    printf("a.out interpreter not yet supported\n");
-    return(0);
-}
-
 void do_init_thread(struct target_pt_regs *regs, struct image_info *infop)
 {
     init_thread(regs, infop);
-- 
1.7.0.1

  parent reply	other threads:[~2010-05-05 18:09 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-05 16:47 [Qemu-devel] [PATCH 00/14] Implement VDSO for x86_64-linux-user Richard Henderson
2010-03-31 22:12 ` [Qemu-devel] [PATCH 01/14] linux-user: Handle filesz < memsz for any PT_LOAD segment Richard Henderson
2010-04-04 18:38 ` [Qemu-devel] [PATCH 13/14] linux-user: Build vdso for x64 Richard Henderson
2010-04-04 19:07 ` [Qemu-devel] [PATCH 03/14] linux-user: Reindent elfload.c Richard Henderson
2010-04-04 19:34 ` [Qemu-devel] [PATCH 04/14] linux-user: Reduce lseek+reads while loading elf files Richard Henderson
2010-04-04 19:35 ` [Qemu-devel] [PATCH 05/14] linux-user: Fix ELF_DATA for Alpha Richard Henderson
2010-04-04 19:54 ` [Qemu-devel] [PATCH 06/14] linux-user: Clean up byte-swapping in elfload.c Richard Henderson
2010-04-04 21:16 ` [Qemu-devel] [PATCH 07/14] linux-user: Load symbols from the interpreter Richard Henderson
2010-04-04 22:04 ` [Qemu-devel] [PATCH 08/14] linux-user: Improve consistency checking in elf headers Richard Henderson
2010-04-04 22:14 ` [Qemu-devel] [PATCH 09/14] linux-user: Put the stack guard page at the top Richard Henderson
2010-04-04 22:31 ` [Qemu-devel] [PATCH 10/14] linux-user: Remove partial support for a.out interpreters Richard Henderson
2010-04-05  0:46 ` [Qemu-devel] [PATCH 11/14] linux-user: Extract load_elf_image from load_elf_interp Richard Henderson
2010-04-05  2:13 ` [Qemu-devel] [PATCH 14/14] linux-user: Load a VDSO for x86-64 Richard Henderson
2010-04-05 16:26 ` [Qemu-devel] [PATCH 02/14] Add more DT_* and AT_* constants to qemu's copy of elf.h Richard Henderson
2010-04-05 16:37 ` [Qemu-devel] [PATCH 12/14] linux-user: Re-use load_elf_image for the main binary Richard Henderson
2010-04-05 18:14   ` malc
2010-04-05 18:38     ` Richard Henderson
2010-04-28 19:36 ` [Qemu-devel] [PATCH 00/14] Implement VDSO for x86-64-linux-user, v2 Richard Henderson
2010-04-28 19:39   ` [Qemu-devel] [PATCH 04/14] linux-user: Reduce lseek+reads while loading elf files Richard Henderson
2010-04-28 19:39   ` [Qemu-devel] [PATCH 01/14] linux-user: Handle filesz < memsz for any PT_LOAD segment Richard Henderson
2010-04-28 19:39   ` [Qemu-devel] [PATCH 02/14] Add more DT_* and AT_* constants to qemu's copy of elf.h Richard Henderson
2010-04-28 19:39   ` [Qemu-devel] [PATCH 09/14] linux-user: Put the stack guard page at the top Richard Henderson
2010-04-28 19:39   ` [Qemu-devel] [PATCH 06/14] linux-user: Clean up byte-swapping in elfload.c Richard Henderson
2010-04-28 19:39   ` [Qemu-devel] [PATCH 05/14] linux-user: Fix ELF_DATA for Alpha Richard Henderson
2010-04-28 19:39   ` [Qemu-devel] [PATCH 10/14] linux-user: Remove partial support for a.out interpreters Richard Henderson
2010-04-28 19:39   ` [Qemu-devel] [PATCH 08/14] linux-user: Improve consistency checking in elf headers Richard Henderson
2010-04-28 19:39   ` [Qemu-devel] [PATCH 11/14] linux-user: Extract load_elf_image from load_elf_interp Richard Henderson
2010-04-28 19:39   ` [Qemu-devel] [PATCH 13/14] linux-user: Build vdso for x64 Richard Henderson
2010-04-28 19:39   ` [Qemu-devel] [PATCH 14/14] linux-user: Load a VDSO for x86-64 Richard Henderson
2010-04-28 19:39   ` [Qemu-devel] [PATCH 12/14] linux-user: Re-use load_elf_image for the main binary Richard Henderson
2010-04-28 19:39   ` [Qemu-devel] [PATCH 03/14] linux-user: Reindent elfload.c Richard Henderson
2010-04-28 19:39   ` [Qemu-devel] [PATCH 07/14] linux-user: Load symbols from the interpreter Richard Henderson
2010-05-05 18:07 ` [Qemu-devel] [PATCH 00/12] Cleanup linux-user/elfload.c, v2 Richard Henderson
2010-05-05 18:07 ` [Qemu-devel] [PATCH 01/12] linux-user: Handle filesz < memsz for any PT_LOAD segment Richard Henderson
2010-05-05 18:07 ` [Qemu-devel] [PATCH 02/12] Add more DT_* and AT_* constants to qemu's copy of elf.h Richard Henderson
2010-05-05 18:07 ` [Qemu-devel] [PATCH 03/12] linux-user: Reindent elfload.c Richard Henderson
2010-05-05 18:07 ` [Qemu-devel] [PATCH 04/12] linux-user: Reduce lseek+reads while loading elf files Richard Henderson
2010-05-05 18:07 ` [Qemu-devel] [PATCH 05/12] linux-user: Define ELF_DATA generically Richard Henderson
2010-05-05 18:07 ` [Qemu-devel] [PATCH 06/12] linux-user: Clean up byte-swapping in elfload.c Richard Henderson
2010-05-05 18:07 ` [Qemu-devel] [PATCH 07/12] linux-user: Load symbols from the interpreter Richard Henderson
2010-05-05 18:07 ` [Qemu-devel] [PATCH 08/12] linux-user: Improve consistency checking in elf headers Richard Henderson
2010-05-05 18:07 ` [Qemu-devel] [PATCH 09/12] linux-user: Put the stack guard page at the top Richard Henderson
2010-05-05 18:07 ` Richard Henderson [this message]
2010-05-05 18:07 ` [Qemu-devel] [PATCH 11/12] linux-user: Extract load_elf_image from load_elf_interp Richard Henderson
2010-05-05 18:07 ` [Qemu-devel] [PATCH 12/12] linux-user: Re-use load_elf_image for the main binary Richard Henderson
  -- strict thread matches above, loose matches on Subject: below --
2010-07-27 17:25 [Qemu-devel] [PATCH 00/12 v4] Clean up linux-user/elfload.c Richard Henderson
2010-07-27 17:25 ` [Qemu-devel] [PATCH 10/12] linux-user: Remove partial support for a.out interpreters Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1273082868-13675-11-git-send-email-rth@twiddle.net \
    --to=rth@twiddle.net \
    --cc=paul@codesourcery.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).