Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys Reworked the o32/n32 matching scheme. IRIX uses some e_f...



details:   https://anonhg.NetBSD.org/src/rev/521ef9efb537
branches:  trunk
changeset: 522573:521ef9efb537
user:      manu <manu%NetBSD.org@localhost>
date:      Thu Feb 21 21:53:00 2002 +0000

description:
Reworked the o32/n32 matching scheme. IRIX uses some e_flags in the ELF
header to distinguish between o32, n32 and n64 ABIs. We now use this.
This suppress the need of the mips_option test, which had some fake positive.
This also removes the mandatory ordering of n32 vs o32 in the exec switch
(exec_conf.c)

diffstat:

 sys/compat/irix/irix_exec.c |  81 ++++----------------------------------------
 sys/compat/irix/irix_exec.h |   8 +++-
 sys/kern/exec_conf.c        |   8 +---
 3 files changed, 17 insertions(+), 80 deletions(-)

diffs (183 lines):

diff -r ba3f462b7a25 -r 521ef9efb537 sys/compat/irix/irix_exec.c
--- a/sys/compat/irix/irix_exec.c       Thu Feb 21 21:52:27 2002 +0000
+++ b/sys/compat/irix/irix_exec.c       Thu Feb 21 21:53:00 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: irix_exec.c,v 1.11 2002/02/20 21:18:18 manu Exp $ */
+/*     $NetBSD: irix_exec.c,v 1.12 2002/02/21 21:53:00 manu Exp $ */
 
 /*-
  * Copyright (c) 2001-2002 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: irix_exec.c,v 1.11 2002/02/20 21:18:18 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: irix_exec.c,v 1.12 2002/02/21 21:53:00 manu Exp $");
 
 #ifndef ELFSIZE
 #define ELFSIZE                32      /* XXX should die */
@@ -60,8 +60,6 @@
 #include <compat/irix/irix_signal.h>
 #include <compat/irix/irix_errno.h>
 
-static int ELFNAME2(irix,mipsopt_signature) __P((struct proc *, 
-    struct exec_package *epp, Elf_Ehdr *eh));
 static void setregs_n32 __P((struct proc *, struct exec_package *, u_long));
 
 extern struct sysent irix_sysent[];
@@ -134,73 +132,8 @@
 #endif
 };
 
-static int
-ELFNAME2(irix,mipsopt_signature)(p, epp, eh)
-       struct proc *p;
-       struct exec_package *epp;
-       Elf_Ehdr *eh;
-{
-       size_t shsize;
-       int     strndx;
-       size_t i;
-       static const char signature[] = ".MIPS.options";
-       char* strtable;
-       Elf_Shdr *sh;
-
-       int error;
-
-       /*
-        * load the section header table
-        */
-       shsize = eh->e_shnum * sizeof(Elf_Shdr);
-       sh = (Elf_Shdr *) malloc(shsize, M_TEMP, M_WAITOK);
-       error = exec_read_from(p, epp->ep_vp, eh->e_shoff, sh, shsize);
-       if (error)
-               goto out;
-
-       /*
-        * Now let's find the string table. If it does not exists, give up.
-        */
-       strndx = (int)(eh->e_shstrndx);
-       if (strndx == SHN_UNDEF) {
-               error = ENOEXEC;
-               goto out;
-       }
-
-       /*
-        * strndx is the index in section header table of the string table
-        * section get the whole string table in strtable, and then we 
-        * get access to the names
-        * s->sh_name is the offset of the section name in strtable.
-        */
-       strtable = malloc(sh[strndx].sh_size, M_TEMP, M_WAITOK);
-       error = exec_read_from(p, epp->ep_vp, sh[strndx].sh_offset, strtable,
-           sh[strndx].sh_size);
-       if (error)
-               goto out;
-
-       for (i = 0; i < eh->e_shnum; i++) {
-               Elf_Shdr *s = &sh[i];
-               if (!memcmp((void*)(&(strtable[s->sh_name])), signature,
-                               sizeof(signature))) {
-#ifdef DEBUG_IRIX
-                       printf("irix_mipsopt_sig=%s\n",&(strtable[s->sh_name]));
-#endif
-                       error = 0;
-                       goto out;
-               }
-       }
-       error = ENOEXEC;
-
-out:
-       free(sh, M_TEMP);
-       free(strtable, M_TEMP);
-       return (error);
-}
-
 /*
  * IRIX o32 ABI probe function
- * Should be run after the IRIX n32 ABI probe function, see comment below
  */
 int
 ELFNAME2(irix,probe_o32)(p, epp, eh, itp, pos)
@@ -217,6 +150,10 @@
 #ifdef DEBUG_IRIX
        printf("irix_probe_o32()\n");
 #endif
+       if ((((Elf_Ehdr *)epp->ep_hdr)->e_flags & IRIX_EF_IRIX_ABI_MASK) !=
+           IRIX_EF_IRIX_ABIO32)
+               return error;
+
        if (itp[0]) {
                /* o32 binaries use /lib/libc.so.1 */
                if (strncmp(itp, "/lib/libc.so", 12) && 
@@ -240,8 +177,6 @@
 
 /*
  * IRIX n32 ABI probe function
- * This should be run before the IRIX o32 ABI probe function, else 
- * n32 static binaries will be matched as o32
  */
 int
 ELFNAME2(irix,probe_n32)(p, epp, eh, itp, pos)
@@ -258,8 +193,8 @@
 #ifdef DEBUG_IRIX
        printf("irix_probe_n32()\n");
 #endif
-       /* This eliminates o32 static binaries */
-       if ((error = ELFNAME2(irix,mipsopt_signature)(p, epp, eh)) != 0)
+       if ((((Elf_Ehdr *)epp->ep_hdr)->e_flags & IRIX_EF_IRIX_ABI_MASK) !=
+           IRIX_EF_IRIX_ABIN32)
                return error;
 
        if (itp[0]) {
diff -r ba3f462b7a25 -r 521ef9efb537 sys/compat/irix/irix_exec.h
--- a/sys/compat/irix/irix_exec.h       Thu Feb 21 21:52:27 2002 +0000
+++ b/sys/compat/irix/irix_exec.h       Thu Feb 21 21:53:00 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: irix_exec.h,v 1.4 2002/01/07 22:05:03 manu Exp $ */
+/*     $NetBSD: irix_exec.h,v 1.5 2002/02/21 21:53:00 manu Exp $ */
 
 /*-
  * Copyright (c) 2001-2002 The NetBSD Foundation, Inc.
@@ -43,6 +43,12 @@
 #include <sys/exec.h>
 #include <sys/exec_elf.h>
 
+/* e_flags used by IRIX for ABI selection */
+#define IRIX_EF_IRIX_ABI64     0x00000010
+#define IRIX_EF_IRIX_ABIN32    0x00000020
+#define IRIX_EF_IRIX_ABIO32    0x00000000
+#define IRIX_EF_IRIX_ABI_MASK  0x00000030
+
 #define IRIX_ELF_AUX_ENTRIES 7
 
 #ifdef EXEC_ELF32
diff -r ba3f462b7a25 -r 521ef9efb537 sys/kern/exec_conf.c
--- a/sys/kern/exec_conf.c      Thu Feb 21 21:52:27 2002 +0000
+++ b/sys/kern/exec_conf.c      Thu Feb 21 21:53:00 2002 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exec_conf.c,v 1.65 2002/01/07 22:07:37 manu Exp $      */
+/*     $NetBSD: exec_conf.c,v 1.66 2002/02/21 21:53:00 manu Exp $      */
 
 /*
  * Copyright (c) 1993, 1994 Christopher G. Demetriou
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: exec_conf.c,v 1.65 2002/01/07 22:07:37 manu Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exec_conf.c,v 1.66 2002/02/21 21:53:00 manu Exp $");
 
 #include "opt_execfmt.h"
 #include "opt_compat_freebsd.h"
@@ -315,10 +315,6 @@
 #endif
 
 #ifdef COMPAT_IRIX 
-       /* 
-        * n32 ABI must be before o32 ABI 
-        * See comments in syssrc/sys/compat/irix/irix_exec_elf32.c
-        */
        /* IRIX Elf32 n32 ABI */
        { sizeof (Elf32_Ehdr),
          exec_elf32_makecmds,



Home | Main Index | Thread Index | Old Index