linux-8086.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: MFLD <mfld.fr@gmail.com>
To: ELKS <Linux-8086@Vger.Kernel.Org>
Subject: [PATCH PROPOSAL] a.out.h port to 64 bits
Date: Mon, 13 Apr 2015 21:54:42 +0200	[thread overview]
Message-ID: <552C1F02.8070302@gmail.com> (raw)

Hello,

DIS88 fails to disassembly 8086 executables when it is built with a 
"64-linux-gnu" chain.
This is because a.out.h uses non-portable integers types, resulting in 
incorrect structure size computation.
Here is a patch that fixes the sizes of the a.out.h structures, using 
C99 fixed-size integers.
Yes, I assume you build DEV86 with a C99 compliant compiler...

MFLD


diff --git a/libc/include/a.out.h b/libc/include/a.out.h
index 677d73e..683e3ec 100644
--- a/libc/include/a.out.h
+++ b/libc/include/a.out.h
@@ -15,18 +15,18 @@
    unsigned char    a_hdrlen;    /* length of header */
    unsigned char    a_unused;    /* reserved for future use */
    unsigned short a_version;    /* version stamp (not used at present) */
-  long        a_text;        /* size of text segement in bytes */
-  long        a_data;        /* size of data segment in bytes */
-  long        a_bss;        /* size of bss segment in bytes */
-  long        a_entry;    /* entry point */
-  long        a_total;    /* total memory allocated */
-  long        a_syms;        /* size of symbol table */
+  u_int32_t        a_text;        /* size of text segement in bytes */
+  u_int32_t        a_data;        /* size of data segment in bytes */
+  u_int32_t        a_bss;        /* size of bss segment in bytes */
+  u_int32_t        a_entry;    /* entry point */
+  u_int32_t        a_total;    /* total memory allocated */
+  u_int32_t        a_syms;        /* size of symbol table */

    /* SHORT FORM ENDS HERE */
-  long        a_trsize;    /* text relocation size */
-  long        a_drsize;    /* data relocation size */
-  long        a_tbase;    /* text relocation base */
-  long        a_dbase;    /* data relocation base */
+  u_int32_t        a_trsize;    /* text relocation size */
+  u_int32_t        a_drsize;    /* data relocation size */
+  u_int32_t        a_tbase;    /* text relocation base */
+  u_int32_t        a_dbase;    /* data relocation base */
  };

  #define A_MAGIC0      (unsigned char) 0x01
@@ -56,7 +56,7 @@

  /* Offsets of various things. */
  #define A_MINHDR    32
-#define    A_TEXTPOS(X)    ((long)(X).a_hdrlen)
+#define    A_TEXTPOS(X)    ((u_int32_t)(X).a_hdrlen)
  #define A_DATAPOS(X)    (A_TEXTPOS(X) + (X).a_text)
  #define    A_HASRELS(X)    ((X).a_hdrlen > (unsigned char) A_MINHDR)
  #define A_HASEXT(X)    ((X).a_hdrlen > (unsigned char) (A_MINHDR +  8))
@@ -68,7 +68,7 @@
                ((X).a_trsize + (X).a_drsize) : 0))

  struct reloc {
-  long r_vaddr;            /* virtual address of reference */
+  u_int32_t r_vaddr;        /* virtual address of reference */
    unsigned short r_symndx;    /* internal segnum or extern symbol num */
    unsigned short r_type;    /* relocation type */
  };
@@ -92,7 +92,7 @@

  struct nlist {            /* symbol table entry */
    char n_name[8];        /* symbol name */
-  long n_value;            /* value */
+  u_int32_t n_value;        /* value */
    unsigned char    n_sclass;    /* storage class */
    unsigned char    n_numaux;    /* number of auxiliary entries (not 
used) */
    unsigned short n_type;    /* language base and derived type (not 
used) */

                 reply	other threads:[~2015-04-13 19:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=552C1F02.8070302@gmail.com \
    --to=mfld.fr@gmail.com \
    --cc=Linux-8086@Vger.Kernel.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 read-only IMAP folder(s) and NNTP newsgroup(s).