diff -cr binutils.26/bfd/aoutx.h e:\emx\gnu\binutils.26/bfd/aoutx.h
*** binutils.26/bfd/aoutx.h	Thu Nov 16 14:56:54 1995
--- e:\emx\gnu\binutils.26/bfd/aoutx.h	Sun Dec 03 03:26:42 1995
***************
*** 1,3 ****
--- 1,4 ----
+ /* aoutx.h -- changed for emx by Eberhard Mattes -- Dec 1995 */
  /* BFD semi-generic back-end for a.out binaries.
     Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
     Written by Cygnus Support.
***************
*** 130,135 ****
--- 131,143 ----
  #include "aout/stab_gnu.h"
  #include "aout/ar.h"
  
+ #ifdef EMX
+ #define IS_STAB(flags) (((flags) & N_STAB) \
+ 	&& (flags) != (N_IMP1|N_EXT) && (flags) != (N_IMP2|N_EXT))
+ #else /* not EMX */
+ #define IS_STAB(flags) ((flags) & N_STAB)
+ #endif /* not EMX */
+ 
  static boolean aout_get_external_symbols PARAMS ((bfd *));
  static boolean translate_from_native_sym_flags
    PARAMS ((bfd *, aout_symbol_type *));
***************
*** 1321,1327 ****
  {
    flagword visible;
  
!   if ((cache_ptr->type & N_STAB) != 0
        || cache_ptr->type == N_FN)
      {
        asection *sec;
--- 1329,1335 ----
  {
    flagword visible;
  
!   if (IS_STAB (cache_ptr->type)
        || cache_ptr->type == N_FN)
      {
        asection *sec;
***************
*** 1544,1549 ****
--- 1552,1569 ----
        cache_ptr->symbol.value -= cache_ptr->symbol.section->vma;
        cache_ptr->symbol.flags = BSF_WEAK;
        break;
+ 
+ #ifdef EMX
+     case N_IMP1 | N_EXT:
+       cache_ptr->symbol.section = bfd_abs_section_ptr;
+       cache_ptr->symbol.flags = BSF_EMX_IMPORT1;
+       break;
+ 
+     case N_IMP2 | N_EXT:
+       cache_ptr->symbol.section = bfd_abs_section_ptr;
+       cache_ptr->symbol.flags = BSF_EMX_IMPORT2;
+       break;
+ #endif /* EMX */
      }
  
    return true;
***************
*** 3042,3048 ****
  	 optimization only, as we check the type more thoroughly
  	 below.  */
        if (((type & N_EXT) == 0
! 	   || (type & N_STAB) != 0
  	   || type == N_FN)
  	  && type != N_WEAKA
  	  && type != N_WEAKT
--- 3062,3068 ----
  	 optimization only, as we check the type more thoroughly
  	 below.  */
        if (((type & N_EXT) == 0
! 	   || IS_STAB (type)
  	   || type == N_FN)
  	  && type != N_WEAKA
  	  && type != N_WEAKT
***************
*** 3250,3256 ****
        type = bfd_h_get_8 (abfd, p->e_type);
  
        /* Ignore debugging symbols.  */
!       if ((type & N_STAB) != 0)
  	continue;
  
        name = strings + GET_WORD (abfd, p->e_strx);
--- 3270,3276 ----
        type = bfd_h_get_8 (abfd, p->e_type);
  
        /* Ignore debugging symbols.  */
!       if (IS_STAB (type))
  	continue;
  
        name = strings + GET_WORD (abfd, p->e_strx);
***************
*** 3948,3954 ****
  	    case strip_none:
  	      break;
  	    case strip_debugger:
! 	      if ((type & N_STAB) != 0)
  		skip = true;
  	      break;
  	    case strip_some:
--- 3968,3974 ----
  	    case strip_none:
  	      break;
  	    case strip_debugger:
! 	      if (IS_STAB (type))
  		skip = true;
  	      break;
  	    case strip_some:
***************
*** 3996,4002 ****
  	      val = GET_WORD (input_bfd, sym->e_value);
  	      symsec = NULL;
  	    }
! 	  else if ((type & N_STAB) != 0)
  	    {
  	      val = GET_WORD (input_bfd, sym->e_value);
  	      symsec = NULL;
--- 4016,4022 ----
  	      val = GET_WORD (input_bfd, sym->e_value);
  	      symsec = NULL;
  	    }
! 	  else if (IS_STAB (type))
  	    {
  	      val = GET_WORD (input_bfd, sym->e_value);
  	      symsec = NULL;
diff -cr binutils.26/bfd/archive.c e:\emx\gnu\binutils.26/bfd/archive.c
*** binutils.26/bfd/archive.c	Fri Nov 10 05:50:22 1995
--- e:\emx\gnu\binutils.26/bfd/archive.c	Sun Dec 03 03:36:04 1995
***************
*** 1,3 ****
--- 1,4 ----
+ /* archive.c -- changed for emx by Eberhard Mattes -- Dec 1995 */
  /* BFD back-end for archive files (libraries).
     Copyright 1990, 91, 92, 93, 94 Free Software Foundation, Inc.
     Written by Cygnus Support.  Mostly Gumby Henkel-Wallace's fault.
***************
*** 1829,1834 ****
--- 1830,1838 ----
  		  if ((flags & BSF_GLOBAL ||
  		       flags & BSF_WEAK ||
  		       flags & BSF_INDIRECT ||
+ #ifdef EMX
+ 		       flags & BSF_EMX_IMPORT1 ||
+ #endif /* EMX */
  		       bfd_is_com_section (sec))
  		      && ! bfd_is_und_section (sec))
  		    {
diff -cr binutils.26/bfd/bfd-in2.h e:\emx\gnu\binutils.26/bfd/bfd-in2.h
*** binutils.26/bfd/bfd-in2.h	Thu Nov 16 14:57:02 1995
--- e:\emx\gnu\binutils.26/bfd/bfd-in2.h	Sun Dec 03 03:48:30 1995
***************
*** 1,3 ****
--- 1,4 ----
+ /* Changed for emx by Eberhard Mattes -- Dec 1995 */
  /* Main header file for the bfd library -- portable access to object files.
     Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
     Contributed by Cygnus Support.
***************
*** 1724,1729 ****
--- 1725,1736 ----
  
  	 /* Symbol is from dynamic linking information.  */
  #define BSF_DYNAMIC	   0x8000
+ 
+ 	 /* Symbol is an emx import reference.  */
+ #define BSF_EMX_IMPORT1  0x20000000
+ 
+ 	 /* Symbol is an emx import definition.  */
+ #define BSF_EMX_IMPORT2  0x40000000
  
    flagword flags;
  
diff -cr binutils.26/bfd/bfd.h e:\emx\gnu\binutils.26/bfd/bfd.h
*** binutils.26/bfd/bfd.h	Sun Dec 03 03:52:46 1995
--- e:\emx\gnu\binutils.26/bfd/bfd.h	Sun Dec 03 03:48:36 1995
***************
*** 1,3 ****
--- 1,4 ----
+ /* Changed for emx by Eberhard Mattes -- Dec 1995 */
  /* Main header file for the bfd library -- portable access to object files.
     Copyright 1990, 1991, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
     Contributed by Cygnus Support.
***************
*** 1724,1729 ****
--- 1725,1736 ----
  
  	 /* Symbol is from dynamic linking information.  */
  #define BSF_DYNAMIC	   0x8000
+ 
+ 	 /* Symbol is an emx import reference.  */
+ #define BSF_EMX_IMPORT1  0x20000000
+ 
+ 	 /* Symbol is an emx import definition.  */
+ #define BSF_EMX_IMPORT2  0x40000000
  
    flagword flags;
  
diff -cr binutils.26/bfd/emx-aout.c e:\emx\gnu\binutils.26/bfd/emx-aout.c
*** binutils.26/bfd/emx-aout.c	Sat Oct 28 01:25:42 1995
--- e:\emx\gnu\binutils.26/bfd/emx-aout.c	Tue Nov 21 14:53:50 1995
***************
*** 1,4 ****
! /* BFD back-end for i386 a.out binaries.
     Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
  
  This file is part of BFD, the Binary File Descriptor library.
--- 1,4 ----
! /* BFD back-end for emx a.out binaries, derived from i386aout.c and aout-target.h
     Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
  
  This file is part of BFD, the Binary File Descriptor library.
***************
*** 27,50 ****
  #define N_HEADER_IN_TEXT(x) 0
  #define BYTES_IN_WORD 4
  
! #define N_TXTOFF(x) 0x20
! #define N_TXTADDR(x) (N_MAGIC(x)==ZMAGIC ? 0x1020 : 0)
  
! #define N_TXTSIZE(x) ((x).a_text)
! #if 0
! #define N_DATADDR(x) (N_MAGIC(x)==OMAGIC? (N_TXTADDR(x)+(x).a_text) : (SEGMENT_SIZE + ((0x1020+(x).a_text-1) & ~(SEGMENT_SIZE-1))))
! #define NOSUBEXECB
! 
! #endif
! #define TARGET_PAGE_SIZE 4096
! #define SEGMENT_SIZE 0x400000
! #define DEFAULT_ARCH bfd_arch_i386
! 
! #define MY(OP) CAT(i386aout_,OP)
! #define TARGETNAME "a.out-i386"
  #define NO_WRITE_HEADER_KLUDGE 1
  
  #include "bfd.h"
  #include "sysdep.h"
  #include "libbfd.h"
  #include "libaout.h"
--- 27,47 ----
  #define N_HEADER_IN_TEXT(x) 0
  #define BYTES_IN_WORD 4
  
! #define TARGET_PAGE_SIZE 0x1000
! #define SEGMENT_SIZE     0x10000
! #define TEXT_START_ADDR  0x10000
! #define DEFAULT_ARCH     bfd_arch_i386
  
! #define MY(OP) CAT(emx_aout_,OP)
! #define TARGETNAME "a.out-emx"
  #define NO_WRITE_HEADER_KLUDGE 1
  
+ #define MY_object_p MY(object_p)
+ 
  #include "bfd.h"
+ 
+ static PROTO (const bfd_target *, MY(object_p), (bfd *abfd));
+ 
  #include "sysdep.h"
  #include "libbfd.h"
  #include "libaout.h"
***************
*** 66,68 ****
--- 63,96 ----
  };
  
  #include "aout-target.h"
+ 
+ /* Finish up the reading of an a.out file header */
+ 
+ static const bfd_target *
+ DEFUN(MY(object_p),(abfd),
+      bfd *abfd)
+ {
+   struct external_exec exec_bytes;	/* Raw exec header from file */
+   struct internal_exec exec;		/* Cleaned-up exec header */
+   const bfd_target *target;
+   long org_pos, add;
+ 
+   org_pos = bfd_tell (abfd);
+   (void)_fseek_hdr(bfd_cache_lookup(abfd));
+   add = bfd_tell (abfd) - org_pos;
+   if (bfd_read ((PTR) &exec_bytes, 1, EXEC_BYTES_SIZE, abfd)
+       != EXEC_BYTES_SIZE) {
+     if (bfd_get_error () != bfd_error_system_call)
+       bfd_set_error (bfd_error_wrong_format);
+     return 0;
+   }
+ 
+   exec.a_info = bfd_h_get_32 (abfd, exec_bytes.e_info);
+ 
+   if (N_BADMAG (exec)) return 0;
+ 
+   NAME(aout,swap_exec_header_in)(abfd, &exec_bytes, &exec);
+   exec.emx_add = add;
+   target = NAME(aout,some_aout_object_p) (abfd, &exec, MY(callback));
+   return target;
+ }
diff -cr binutils.26/bfd/libaout.h e:\emx\gnu\binutils.26/bfd/libaout.h
*** binutils.26/bfd/libaout.h	Thu Nov 16 14:57:30 1995
--- e:\emx\gnu\binutils.26/bfd/libaout.h	Tue Nov 21 14:23:04 1995
***************
*** 1,3 ****
--- 1,5 ----
+ /* libaout.h -- changed for emx by Eberhard Mattes -- Nov 1995 */
+ 
  /* BFD back-end data structures for a.out (and similar) files.
     Copyright 1990, 1991, 1992 Free Software Foundation, Inc.
     Written by Cygnus Support.
***************
*** 175,180 ****
--- 177,185 ----
  struct internal_exec
  {
      long a_info;		/* Magic number and flags, packed */
+ #if defined (__EMX__)
+     long emx_add;
+ #endif
      bfd_vma a_text;		/* length of text, in bytes  */
      bfd_vma a_data;		/* length of data, in bytes  */
      bfd_vma a_bss;		/* length of uninitialized data area in mem */
diff -cr binutils.26/bfd/syms.c e:\emx\gnu\binutils.26/bfd/syms.c
*** binutils.26/bfd/syms.c	Tue Sep 26 17:56:40 1995
--- e:\emx\gnu\binutils.26/bfd/syms.c	Sun Dec 03 03:26:18 1995
***************
*** 1,3 ****
--- 1,4 ----
+ /* syms.c -- changed for emx by Eberhard Mattes -- Dec 1995 */
  /* Generic symbol-table support for the BFD library.
     Copyright (C) 1990, 1991, 1992, 1993 Free Software Foundation, Inc.
     Written by Cygnus Support.
***************
*** 280,285 ****
--- 281,292 ----
  .	{* Symbol is from dynamic linking information.  *}
  .#define BSF_DYNAMIC	   0x8000
  .
+ .	{* Symbol is an emx import reference.  *}
+ .#define BSF_EMX_IMPORT1   0x20000000
+ .
+ .	{* Symbol is an emx import definition.  *}
+ .#define BSF_EMX_IMPORT2   0x40000000
+ .
  .  flagword flags;
  .
  .	{* A pointer to the section to which this symbol is
***************
*** 422,427 ****
--- 429,438 ----
  	   ((type & BSF_LOCAL)
  	    ? (type & BSF_GLOBAL) ? '!' : 'l'
  	    : (type & BSF_GLOBAL) ? 'g' : ' '),
+ #ifdef EMX
+ 	   (type & BSF_EMX_IMPORT1) ? 'e' :
+ 	   (type & BSF_EMX_IMPORT2) ? 'E' :
+ #endif /* EMX */
  	   (type & BSF_WEAK) ? 'w' : ' ',
  	   (type & BSF_CONSTRUCTOR) ? 'C' : ' ',
  	   (type & BSF_WARNING) ? 'W' : ' ',
***************
*** 535,540 ****
--- 546,557 ----
      return 'I';
    if (symbol->flags & BSF_WEAK)
      return 'W';
+ #ifdef EMX
+   if (symbol->flags & BSF_EMX_IMPORT1)
+     return 'e';
+   if (symbol->flags & BSF_EMX_IMPORT2)
+     return 'E';
+ #endif /* EMX */
    if (!(symbol->flags & (BSF_GLOBAL | BSF_LOCAL)))
      return '?';
  
diff -cr binutils.26/bfd/targets.c e:\emx\gnu\binutils.26/bfd/targets.c
*** binutils.26/bfd/targets.c	Thu Nov 16 14:57:40 1995
--- e:\emx\gnu\binutils.26/bfd/targets.c	Tue Nov 21 14:29:46 1995
***************
*** 1,3 ****
--- 1,4 ----
+ /* targets.c -- changed for emx by Eberhard Mattes -- Nov 1995 */
  /* Generic target-file-type support for the BFD library.
     Copyright 1990, 91, 92, 93, 94, 1995 Free Software Foundation, Inc.
     Written by Cygnus Support.
***************
*** 493,498 ****
--- 494,502 ----
  extern const bfd_target ecoff_big_vec;
  extern const bfd_target ecoff_little_vec;
  extern const bfd_target ecoffalpha_little_vec;
+ #ifdef EMX
+ extern const bfd_target emx_aout_vec;
+ #endif /* EMX */
  extern const bfd_target h8300coff_vec;
  extern const bfd_target h8500coff_vec;
  extern const bfd_target host_aout_vec;
diff -cr binutils.26/bfd/trad-cor.c e:\emx\gnu\binutils.26/bfd/trad-cor.c
*** binutils.26/bfd/trad-cor.c	Tue Oct 31 21:32:42 1995
--- e:\emx\gnu\binutils.26/bfd/trad-cor.c	Tue Nov 21 14:23:08 1995
***************
*** 1,3 ****
--- 1,4 ----
+ /* trad-cor.c -- changed for emx by Eberhard Mattes -- Nov 1995 */
  /* BFD back end for traditional Unix core files (U-area and raw sections)
     Copyright 1988, 1989, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
     Written by John Gilmore of Cygnus Support.
***************
*** 38,43 ****
--- 39,47 ----
    struct trad_core_struct 
      {
        asection *data_section;
+ #ifdef __EMX__
+       asection *heap_section;
+ #endif /* __EMX__ */
        asection *stack_section;
        asection *reg_section;
        struct user u;
***************
*** 45,50 ****
--- 49,57 ----
  
  #define core_upage(bfd) (&((bfd)->tdata.trad_core_data->u))
  #define core_datasec(bfd) ((bfd)->tdata.trad_core_data->data_section)
+ #ifdef __EMX__
+ #define core_heapsec(bfd) ((bfd)->tdata.trad_core_data->heap_section)
+ #endif /* __EMX__ */
  #define core_stacksec(bfd) ((bfd)->tdata.trad_core_data->stack_section)
  #define core_regsec(bfd) ((bfd)->tdata.trad_core_data->reg_section)
  
***************
*** 83,88 ****
--- 90,99 ----
      }
  
    /* Sanity check perhaps??? */
+ #ifdef __EMX__
+   if (u.u_magic != UMAGIC)
+     return 0;
+ #else /* !__EMX__ */
    if (u.u_dsize > 0x1000000)	/* Remember, it's in pages... */
      {
        bfd_set_error (bfd_error_wrong_format);
***************
*** 129,134 ****
--- 140,146 ----
        }
  #endif
    }
+ #endif /* !__EMX__ */
  
    /* OK, we believe you.  You're a core file (sure, sure).  */
  
***************
*** 163,180 ****
    }
    core_regsec (abfd) = (asection *) bfd_zmalloc (sizeof (asection));
    if (core_regsec (abfd) == NULL) {
      free ((void *)core_datasec (abfd));
      goto loser1;
    }
  
    core_stacksec (abfd)->name = ".stack";
    core_datasec (abfd)->name = ".data";
    core_regsec (abfd)->name = ".reg";
  
    core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
    core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
    core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
! 
    core_datasec (abfd)->_raw_size =  NBPG * u.u_dsize
  #ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE
      - NBPG * u.u_tsize
--- 175,214 ----
    }
    core_regsec (abfd) = (asection *) bfd_zmalloc (sizeof (asection));
    if (core_regsec (abfd) == NULL) {
+ #ifdef EMX
+   loser2:
+ #endif /* EMX */
      free ((void *)core_datasec (abfd));
      goto loser1;
    }
+ #ifdef EMX
+   core_heapsec (abfd) = (asection *) bfd_zmalloc (sizeof (asection));
+   if (core_heapsec (abfd) == NULL) {
+     free ((void *)core_regsec (abfd));
+     goto loser2;
+   }
+ #endif /* EMX */
  
    core_stacksec (abfd)->name = ".stack";
    core_datasec (abfd)->name = ".data";
+ #ifdef EMX
+   core_heapsec (abfd)->name = ".heap";
+ #endif /* EMX */
    core_regsec (abfd)->name = ".reg";
  
    core_stacksec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
    core_datasec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
    core_regsec (abfd)->flags = SEC_HAS_CONTENTS;
! #ifdef EMX
!   core_heapsec (abfd)->flags = SEC_ALLOC + SEC_LOAD + SEC_HAS_CONTENTS;
! #endif /* EMX */
! 
! #ifdef EMX
!   core_datasec (abfd)->_raw_size =  u.u_data_end - u.u_data_base;
!   core_heapsec (abfd)->_raw_size = u.u_heap_brk - u.u_heap_base;
!   core_stacksec (abfd)->_raw_size = u.u_stack_end - u.u_stack_low;
!   core_regsec (abfd)->_raw_size = sizeof (struct user);
! #else /* not EMX */
    core_datasec (abfd)->_raw_size =  NBPG * u.u_dsize
  #ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE
      - NBPG * u.u_tsize
***************
*** 182,190 ****
--- 216,230 ----
        ;
    core_stacksec (abfd)->_raw_size = NBPG * u.u_ssize;
    core_regsec (abfd)->_raw_size = NBPG * UPAGES; /* Larger than sizeof struct u */
+ #endif /* not EMX */
  
    /* What a hack... we'd like to steal it from the exec file,
       since the upage does not seem to provide it.  FIXME.  */
+ #ifdef EMX
+   core_datasec (abfd)->vma = u.u_data_base;
+   core_heapsec (abfd)->vma = u.u_heap_base;
+   core_stacksec (abfd)->vma = u.u_stack_low;
+ #else /* not EMX */
  #ifdef HOST_DATA_START_ADDR
    core_datasec (abfd)->vma = HOST_DATA_START_ADDR;
  #else
***************
*** 196,201 ****
--- 236,242 ----
  #else
    core_stacksec (abfd)->vma = HOST_STACK_END_ADDR - (NBPG * u.u_ssize);
  #endif
+ #endif /* not EMX */
  
    /* This is tricky.  As the "register section", we give them the entire
       upage and stack.  u.u_ar0 points to where "register 0" is stored.
***************
*** 213,235 ****
--- 254,291 ----
       using minor trickery to get around the offset-or-absolute-addr problem. */
    core_regsec (abfd)->vma = 0 - (bfd_vma) u.u_ar0;
  
+ #ifdef EMX
+   core_datasec (abfd)->filepos = u.u_data_off;
+   core_heapsec (abfd)->filepos = u.u_heap_off;
+   core_stacksec (abfd)->filepos = u.u_stack_off;
+ #else /* not EMX */
    core_datasec (abfd)->filepos = NBPG * UPAGES;
    core_stacksec (abfd)->filepos = (NBPG * UPAGES) + NBPG * u.u_dsize
  #ifdef TRAD_CORE_DSIZE_INCLUDES_TSIZE
      - NBPG * u.u_tsize
  #endif
        ;
+ #endif /* not EMX */
    core_regsec (abfd)->filepos = 0; /* Register segment is the upage */
  
    /* Align to word at least */
    core_stacksec (abfd)->alignment_power = 2;
    core_datasec (abfd)->alignment_power = 2;
+ #ifdef EMX
+   core_heapsec (abfd)->alignment_power = 2;
+ #endif /* EMX */
    core_regsec (abfd)->alignment_power = 2;
  
    abfd->sections = core_stacksec (abfd);
    core_stacksec (abfd)->next = core_datasec (abfd);
+ #ifdef EMX
+   core_datasec (abfd)->next = core_heapsec (abfd);
+   core_heapsec (abfd)->next = core_regsec (abfd);
+   abfd->section_count = 4;
+ #else /* not EMX */
    core_datasec (abfd)->next = core_regsec (abfd);
    abfd->section_count = 3;
+ #endif /* not EMX */
  
    return abfd->xvec;
  }
diff -cr binutils.26/binutils/ar.c e:\emx\gnu\binutils.26/binutils/ar.c
*** binutils.26/binutils/ar.c	Mon Nov 06 21:02:38 1995
--- e:\emx\gnu\binutils.26/binutils/ar.c	Sat Nov 25 13:39:32 1995
***************
*** 1,3 ****
--- 1,4 ----
+ /* ar.c -- changed for emx by Eberhard Mattes -- Nov 1995 */
  /* ar.c - Archive modify and extract.
     Copyright 1991, 92, 93, 94 Free Software Foundation, Inc.
  
***************
*** 41,47 ****
  #endif /* HAVE_UTIMES */
  #endif /* ! HAVE_GOOD_UTIME_H */
  
! #ifdef __GO32___
  #define EXT_NAME_LEN 3		/* bufflen of addition to name if it's MS-DOS */
  #else
  #define EXT_NAME_LEN 6		/* ditto for *NIX */
--- 42,48 ----
  #endif /* HAVE_UTIMES */
  #endif /* ! HAVE_GOOD_UTIME_H */
  
! #if defined (__GO32___) || defined (__EMX__)
  #define EXT_NAME_LEN 3		/* bufflen of addition to name if it's MS-DOS */
  #else
  #define EXT_NAME_LEN 6		/* ditto for *NIX */
***************
*** 241,251 ****
--- 242,256 ----
  {
    const char *filename;
  
+ #ifdef __EMX__
+   filename = _getname (file);
+ #else /* not __EMX__ */
    filename = strrchr (file, '/');
    if (filename != (char *) NULL)
      filename++;
    else
      filename = file;
+ #endif /* not __EMX__ */
  
    if (ar_truncate
        && abfd != NULL
***************
*** 303,308 ****
--- 308,317 ----
    char *temp;
    int show_version;
  
+ #ifdef __EMX__
+   _wildcard (&argc, &argv);
+   _response (&argc, &argv);
+ #endif /* __EMX__ */
    program_name = argv[0];
    xmalloc_set_program_name (program_name);
  
***************
*** 313,323 ****
--- 322,338 ----
  
    xatexit (remove_output);
  
+ #ifdef __EMX__
+   temp = strdup (_getname (program_name));
+   _remext (temp);
+   strlwr (temp);
+ #else /* not __EMX__ */
    temp = strrchr (program_name, '/');
    if (temp == (char *) NULL)
      temp = program_name;	/* shouldn't happen, but... */
    else
      ++temp;
+ #endif /* not __EMX__ */
    if (is_ranlib > 0 || (is_ranlib < 0 && strcmp (temp, "ranlib") == 0))
      {
        boolean touch = false;
***************
*** 438,443 ****
--- 453,463 ----
  	case 'f':
  	  ar_truncate = true;
  	  break;
+ #ifdef __EMX__
+         case 'J':
+           /* Silently ignore `J' for backward compatibility. */
+           break;
+ #endif /* __EMX__ */
  	default:
  	  fprintf (stderr, "%s: illegal option -- %c\n", program_name, c);
  	  usage ();
diff -cr binutils.26/binutils/bucomm.c e:\emx\gnu\binutils.26/binutils/bucomm.c
*** binutils.26/binutils/bucomm.c	Mon Nov 06 21:02:42 1995
--- e:\emx\gnu\binutils.26/binutils/bucomm.c	Tue Nov 28 12:47:00 1995
***************
*** 1,3 ****
--- 1,4 ----
+ /* bucomm.c -- changed for emx by Eberhard Mattes -- Nov 1995 */
  /* bucomm.c -- Bin Utils COMmon code.
     Copyright (C) 1991, 92, 93, 94 Free Software Foundation, Inc.
  
***************
*** 173,179 ****
--- 174,188 ----
  {
    static char template[] = "stXXXXXX";
    char *tmpname;
+ #ifdef __EMX__
+   char *slash = _getname (filename);
+   if (slash == filename)
+     slash = NULL;
+   else
+     slash -= 1;
+ #else /* not __EMX__ */
    char *slash = strrchr (filename, '/');
+ #endif /* not __EMX__ */
  
    if (slash != (char *) NULL)
      {
diff -cr binutils.26/binutils/nm.c e:\emx\gnu\binutils.26/binutils/nm.c
*** binutils.26/binutils/nm.c	Wed Nov 15 18:17:04 1995
--- e:\emx\gnu\binutils.26/binutils/nm.c	Tue Nov 21 14:23:14 1995
***************
*** 1,3 ****
--- 1,4 ----
+ /* nm.c -- changed for emx by Eberhard Mattes -- Nov 1995 */
  /* nm.c -- Describe symbol table of a rel file.
     Copyright 1991, 92, 93, 94 Free Software Foundation, Inc.
  
***************
*** 337,342 ****
--- 338,347 ----
    int c;
    int retval;
  
+ #ifdef __EMX__
+   _wildcard (&argc, &argv);
+   _response (&argc, &argv);
+ #endif /* __EMX__ */
    program_name = *argv;
    xmalloc_set_program_name (program_name);
  
diff -cr binutils.26/binutils/objdump.c e:\emx\gnu\binutils.26/binutils/objdump.c
*** binutils.26/binutils/objdump.c	Wed Nov 15 18:16:16 1995
--- e:\emx\gnu\binutils.26/binutils/objdump.c	Tue Nov 21 14:23:16 1995
***************
*** 1,3 ****
--- 1,4 ----
+ /* objdump.c -- changed for emx by Eberhard Mattes -- Nov 1995 */
  /* objdump.c -- dump information about an object file.
     Copyright 1990, 1991, 1992, 1993, 1994 Free Software Foundation, Inc.
  
***************
*** 1836,1841 ****
--- 1837,1846 ----
    char *target = default_target;
    boolean seenflag = false;
  
+ #ifdef __EMX__
+   _wildcard (&argc, &argv);
+   _response (&argc, &argv);
+ #endif /* __EMX__ */
    program_name = *argv;
    xmalloc_set_program_name (program_name);
  
diff -cr binutils.26/binutils/size.c e:\emx\gnu\binutils.26/binutils/size.c
*** binutils.26/binutils/size.c	Wed Sep 06 01:52:24 1995
--- e:\emx\gnu\binutils.26/binutils/size.c	Tue Nov 21 14:23:16 1995
***************
*** 1,3 ****
--- 1,4 ----
+ /* size.c -- changed for emx by Eberhard Mattes -- Nov 1995 */
  /* size.c -- report size of various sections of an executable file.
     Copyright 1991, 92, 93, 94 Free Software Foundation, Inc.
  
***************
*** 97,102 ****
--- 98,107 ----
    int temp;
    int c;
  
+ #ifdef __EMX__
+   _wildcard (&argc, &argv);
+   _response (&argc, &argv);
+ #endif /* __EMX__ */
    program_name = *argv;
    xmalloc_set_program_name (program_name);
  
diff -cr binutils.26/gas/as.c e:\emx\gnu\binutils.26/gas/as.c
*** binutils.26/gas/as.c	Wed Nov 15 11:55:16 1995
--- e:\emx\gnu\binutils.26/gas/as.c	Thu Nov 30 15:29:12 1995
***************
*** 1,3 ****
--- 1,5 ----
+ /* as.c -- changed for emx by Eberhard Mattes -- Nov 1995 */
+ 
  /* as.c - GAS main program.
     Copyright (C) 1987, 1990, 1991, 1992, 1994 Free Software Foundation, Inc.
  
***************
*** 32,37 ****
--- 34,47 ----
   *
   */
  
+ #ifdef EMX
+ #include <process.h>
+ #include <io.h>
+ static char *omf_file_name;
+ int emx_omf;                    /* -Zomf */
+ int emx_strip;                  /* -Zstrip */
+ #endif /* EMX */
+ 
  #include "ansidecl.h"
  #include "libiberty.h"
  
***************
*** 512,517 ****
--- 522,534 ----
    int keep_it;
    long start_time = get_run_time ();
  
+ #ifdef __EMX__
+   _emxload_env ("GCCLOAD");
+   _envargs (&argc, &argv, "GASOPT");
+   _response (&argc, &argv);
+   _wildcard (&argc, &argv);
+ #endif /* __EMX__ */
+ 
    if (debug_memory)
      {
  #ifdef BFD_ASSEMBLER
***************
*** 570,575 ****
--- 587,614 ----
  
    PROGRESS (1);
  
+ #ifdef EMX
+   if (emx_omf)
+     {
+       char *tmp_dir;
+       size_t tmp_dir_len;
+ 
+       omf_file_name = out_file_name;
+       tmp_dir = getenv ("TMPDIR");
+       if (tmp_dir == NULL) tmp_dir = getenv ("TMP");
+       if (tmp_dir == NULL) tmp_dir = getenv ("TEMP");
+       if (tmp_dir == NULL) tmp_dir = ".";
+       tmp_dir_len = strlen (tmp_dir);
+       out_file_name = xmalloc (tmp_dir_len + 10);
+       memcpy (out_file_name, tmp_dir, tmp_dir_len);
+       if (tmp_dir_len != 0 && strchr ("\\/:", tmp_dir[tmp_dir_len-1]) == NULL)
+         out_file_name[tmp_dir_len++] = '\\';
+       strcpy (out_file_name + tmp_dir_len, "asXXXXXX");
+       if (mktemp (out_file_name) == NULL)
+         as_fatal ("mktemp() failed");
+     }
+ #endif /* EMX */
+ 
  #ifdef BFD_ASSEMBLER
    output_file_create (out_file_name);
    assert (stdoutput != 0);
***************
*** 610,615 ****
--- 649,677 ----
  
    if (!keep_it)
      unlink (out_file_name);
+ 
+ #ifdef EMX
+   if (keep_it && emx_omf)
+     {
+       int rc, i;
+       char *args[6];
+ 
+       i = 0;
+       args[i++] = "emxomf";
+       if (emx_strip)
+ 	args[i++] = "-s";
+       args[i++] = "-o";
+       args[i++] = omf_file_name;
+       args[i++] = out_file_name;
+       args[i] = NULL;
+       rc = spawnvp (P_WAIT, "emxomf.exe", args);
+       remove (out_file_name);
+       if (rc < 0)
+         as_fatal ("cannot run emxomf");
+       else if (rc > 0)
+         as_fatal ("emxomf failed");
+     }
+ #endif /* EMX */
  
    input_scrub_end ();
  
diff -cr binutils.26/gas/targ-cpu.c e:\emx\gnu\binutils.26/gas/targ-cpu.c
*** binutils.26/gas/targ-cpu.c	Wed Nov 15 11:55:36 1995
--- e:\emx\gnu\binutils.26/gas/targ-cpu.c	Thu Nov 30 01:20:34 1995
***************
*** 1,3 ****
--- 1,4 ----
+ /* targ-cpu.c -- changed for emx by Eberhard Mattes -- Nov 1995 */
  /* i386.c -- Assemble code for the Intel 80386
     Copyright (C) 1989, 1991, 1992, 1993 Free Software Foundation.
  
***************
*** 2784,2793 ****
--- 2785,2805 ----
  CONST char *md_shortopts = "m";
  #endif
  struct option md_longopts[] = {
+ #ifdef EMX
+ #define OPTION_ZOMF (OPTION_MD_BASE)
+   {"Zomf", no_argument, NULL, OPTION_ZOMF},
+ #define OPTION_ZSTRIP (OPTION_MD_BASE+1)
+   {"Zstrip", no_argument, NULL, OPTION_ZSTRIP},
+ #endif /* EMX */
    {NULL, no_argument, NULL, 0}
  };
  size_t md_longopts_size = sizeof(md_longopts);
  
+ #ifdef EMX
+ extern int emx_omf;
+ extern int emx_strip;
+ #endif /* EMX */
+ 
  int
  md_parse_option (c, arg)
       int c;
***************
*** 2810,2815 ****
--- 2822,2837 ----
      case 'Q':
        break;
  #endif
+ 
+ #ifdef EMX
+     case OPTION_ZOMF:
+       emx_omf = 1;
+       break;
+ 
+     case OPTION_ZSTRIP:
+       emx_strip = 1;
+       break;
+ #endif /* EMX */
  
      default:
        return 0;
diff -cr binutils.26/gprof/gmon.h e:\emx\gnu\binutils.26/gprof/gmon.h
*** binutils.26/gprof/gmon.h	Wed Feb 08 03:35:08 1995
--- e:\emx\gnu\binutils.26/gprof/gmon.h	Tue Nov 21 15:25:00 1995
***************
*** 51,58 ****
--- 51,63 ----
  
  /*
   * Histogram counters are unsigned shorts:
+  * For emx, histogram counters are unsigned longs.
   */
+ #if 1 /* emx */
+ #define	HISTCOUNTER unsigned long
+ #else
  #define	HISTCOUNTER unsigned short
+ #endif
  
  /*
   * Fraction of text space to allocate for histogram counters here, 1/2:
diff -cr binutils.26/gprof/hertz.c e:\emx\gnu\binutils.26/gprof/hertz.c
*** binutils.26/gprof/hertz.c	Tue Mar 14 03:57:56 1995
--- e:\emx\gnu\binutils.26/gprof/hertz.c	Tue Nov 21 14:23:16 1995
***************
*** 23,28 ****
--- 23,32 ----
  #ifdef __MSDOS__
  #define HERTZ 18
  #endif
+ #ifdef __EMX__
+ #include <stdlib.h>
+ #define HERTZ (_osmode == OS2_MODE ? 1000 : 1024)
+ #endif
  
  int
  hertz ()
diff -cr binutils.26/gprof/i386.h e:\emx\gnu\binutils.26/gprof/i386.h
*** binutils.26/gprof/i386.h	Wed Feb 08 03:35:20 1995
--- e:\emx\gnu\binutils.26/gprof/i386.h	Sat Dec 02 19:17:00 1995
***************
*** 36,38 ****
--- 36,42 ----
  #ifdef __MSDOS__
  #define FOPEN_RB "rb"
  #endif
+ 
+ #ifdef __EMX__
+ #define FOPEN_RB "rb"
+ #endif
diff -cr binutils.26/gprof/source.c e:\emx\gnu\binutils.26/gprof/source.c
*** binutils.26/gprof/source.c	Tue Mar 14 03:58:02 1995
--- e:\emx\gnu\binutils.26/gprof/source.c	Sat Dec 02 19:23:22 1995
***************
*** 104,110 ****
--- 104,114 ----
      {
        DBG (SRCDEBUG, printf ("[annotate_source]: looking for %s, trying %s\n",
  			     sf->name, fname));
+ #ifdef __EMX__
+       ifp = fopen (fname, "r");
+ #else /* not __EMX__ */
        ifp = fopen (fname, FOPEN_RB);
+ #endif /* not __EMX__ */
        if (ifp)
  	{
  	  break;
diff -cr binutils.26/include/aout/aout64.h e:\emx\gnu\binutils.26/include/aout/aout64.h
*** binutils.26/include/aout/aout64.h	Sat Oct 28 01:51:48 1995
--- e:\emx\gnu\binutils.26/include/aout/aout64.h	Sun Dec 03 03:21:00 1995
***************
*** 1,3 ****
--- 1,4 ----
+ /* aout64.h -- changed for emx by Eberhard Mattes -- Dec 1995 */
  /* `a.out' object-file definitions, including extensions to 64-bit fields */
  
  #ifndef __A_OUT_64_H__
***************
*** 300,305 ****
--- 301,310 ----
  #define N_WEAKT 0x0f		/* Weak text symbol.  */
  #define N_WEAKD 0x10		/* Weak data symbol.  */
  #define N_WEAKB 0x11		/* Weak bss symbol.  */
+ 
+ /* emx-specific symbols.  */
+ #define N_IMP1 0x68		/* Import reference (emx specific) */
+ #define N_IMP2 0x6a		/* Import definition (emx specific) */
  
  /* Relocations 
  
diff -cr binutils.26/libibert/cplus-de.c e:\emx\gnu\binutils.26/libibert/cplus-de.c
*** binutils.26/libibert/cplus-de.c	Thu Jun 29 03:22:52 1995
--- e:\emx\gnu\binutils.26/libibert/cplus-de.c	Tue Nov 21 14:59:18 1995
***************
*** 1,3 ****
--- 1,4 ----
+ /* cplus-de.c -- changed for emx by Eberhard Mattes -- Nov 1995 */
  /* Demangler for GNU C++ 
     Copyright 1989, 1991, 1994, 1995 Free Software Foundation, Inc.
     Written by James Clark (jjc@jclark.uucp)
***************
*** 216,222 ****
  #endif
  
  static int
! demangle_template PARAMS ((struct work_stuff *work, const char **, string *,
  			   string *));
  
  static int
--- 217,223 ----
  #endif
  
  static int
! demangle_template PARAMS ((struct work_stuff *, const char **, string *,
  			   string *));
  
  static int
