Source-Changes-HG archive

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

[src/trunk]: src/usr.bin/elf2aout Set a_midmag MAGIC in a.out header properly...



details:   https://anonhg.NetBSD.org/src/rev/cd294c652bca
branches:  trunk
changeset: 767165:cd294c652bca
user:      tsutsui <tsutsui%NetBSD.org@localhost>
date:      Sun Jul 10 04:56:31 2011 +0000

description:
Set a_midmag MAGIC in a.out header properly for more possible a.out ports
in the past per ex.e_machine in ELF header.

diffstat:

 usr.bin/elf2aout/elf2aout.c |  37 ++++++++++++++++++++++++++++++++-----
 1 files changed, 32 insertions(+), 5 deletions(-)

diffs (58 lines):

diff -r 657f62e95bbe -r cd294c652bca usr.bin/elf2aout/elf2aout.c
--- a/usr.bin/elf2aout/elf2aout.c       Sun Jul 10 04:52:23 2011 +0000
+++ b/usr.bin/elf2aout/elf2aout.c       Sun Jul 10 04:56:31 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: elf2aout.c,v 1.13 2011/06/28 13:15:24 tsutsui Exp $    */
+/*     $NetBSD: elf2aout.c,v 1.14 2011/07/10 04:56:31 tsutsui Exp $    */
 
 /*
  * Copyright (c) 1995
@@ -75,6 +75,7 @@
        struct exec aex;
        int     infile, outfile;
        unsigned long cur_vma = ULONG_MAX;
+       unsigned long mid;
        int     symflag = 0;
 
        strtabix = symtabix = 0;
@@ -209,10 +210,36 @@
                text.len = data.vaddr - text.vaddr;
 
        /* We now have enough information to cons up an a.out header... */
-       aex.a_midmag = htonl((symflag << 26) | (MID_PMAX << 16) | OMAGIC);
-       if (ex.e_machine == EM_PPC)
-               aex.a_midmag = htonl((symflag << 26) | (MID_POWERPC << 16)
-                       | OMAGIC);
+       switch (ex.e_machine) {
+       case EM_SPARC:
+               mid = MID_SPARC;
+               break;
+       case EM_386:
+               mid = MID_PC386;
+               break;
+       case EM_68K:
+               mid = MID_M68K;
+               break;
+       case EM_MIPS:
+               if (ex.e_ident[EI_DATA] == ELFDATA2LSB)
+                       mid = MID_PMAX;
+               else
+                       mid = MID_MIPS;
+               break;
+       case EM_PPC:
+               mid = MID_POWERPC;
+               break;
+       case EM_ARM:
+               mid = MID_ARM6;
+               break;
+       case EM_VAX:
+               mid = MID_VAX;
+               break;
+       case EM_NONE:
+       default:
+               mid = MID_ZERO;
+       }
+       aex.a_midmag = htonl((symflag << 26) | (mid << 16) | OMAGIC);
 
        aex.a_text = text.len;
        aex.a_data = data.len;



Home | Main Index | Thread Index | Old Index