public inbox for linux-8086@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH PROPOSAL] a.out.h port to 64 bits
@ 2015-04-13 19:54 MFLD
  0 siblings, 0 replies; only message in thread
From: MFLD @ 2015-04-13 19:54 UTC (permalink / raw)
  To: ELKS

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) */

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2015-04-13 19:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-13 19:54 [PATCH PROPOSAL] a.out.h port to 64 bits MFLD

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox