diff -c ./ar.c c:\emx\gnu\binutils.old/ar.c
*** ./ar.c	Wed Jun 13 06:47:50 1990
--- c:\emx\gnu\binutils.old/ar.c	Mon Nov 14 20:12:16 1994
***************
*** 1,3 ****
--- 1,5 ----
+ /* ar.c -- changed for emx by Eberhard Mattes -- Nov 1994 */
+ 
  /* ar.c - Archive modify and extract.
     Copyright (C) 1988 Free Software Foundation, Inc.
  
***************
*** 20,25 ****
--- 22,30 ----
  #include <errno.h>
  #include <sys/types.h>
  #include <sys/stat.h>
+ #ifdef __EMX__
+ #include <stdlib.h>
+ #endif /* __EMX__ */
  
  #if !defined(A_OUT) && !defined(MACH_O)
  #define A_OUT
***************
*** 29,35 ****
--- 34,44 ----
  #ifdef COFF_ENCAPSULATE
  #include "a.out.encap.h"
  #else
+ #ifdef __EMX__
+ #include <a_out.h>
+ #else /* not __EMX__ */
  #include <a.out.h>
+ #endif /* not __EMX__ */
  #endif
  #endif
  
***************
*** 142,147 ****
--- 151,164 ----
  
  int preserve_dates;
  
+ #ifdef EMX
+ /* Nonzero means remove directory names from members when replacing
+    members.  */
+ 
+ int junk_paths;
+ 
+ #endif /* EMX */
+ 
  /* Operation to be performed.  */
  
  #define DELETE 1
***************
*** 298,303 ****
--- 315,324 ----
    files = 0;
    lock_indesc = -1;
  
+ #ifdef __EMX__
+   _response (&argc, &argv);
+   _wildcard (&argc, &argv);
+ #endif /* __EMX__ */
    if (argc < 2)
      usage ("too few command arguments", 0);
  
***************
*** 388,393 ****
--- 409,420 ----
  	      two_operations ();
  	    operation = EXTRACT;
  	    break;
+ 
+ #ifdef EMX
+ 	  case 'J':
+ 	    junk_paths = 1;
+ 	    break;
+ #endif /* EMX */
  	  }
        }
    
***************
*** 470,476 ****
--- 497,507 ----
       void (*function) ();
       int crflag;
  {
+ #ifdef __EMX__
+   FILE *arcstream = fopen (archive, "rb");
+ #else /* not __EMX__ */
    FILE *arcstream = fopen (archive, "r");
+ #endif /* not __EMX__ */
  
    if (arcstream == 0 && crflag)
      /* Creation-warning, if desired, will happen later.  */
***************
*** 591,597 ****
--- 622,632 ----
    FILE *ostream;
  
    fseek (istream, member.data_offset, 0);
+ #ifdef __EMX__
+   ostream = fopen (member.name, "wb");
+ #else /* not __EMX__ */
    ostream = fopen (member.name, "w");
+ #endif /* not __EMX__ */
    if (!ostream)
      {
        perror_with_name (member.name);
***************
*** 614,624 ****
--- 649,663 ----
        ncopied += tocopy;
      }
  
+ #ifdef __EMX__
+   chmod (member.name, member.mode);
+ #else /* not __EMX__ */
  #ifdef USG
    chmod (member.name, member.mode);
  #else
    fchmod (fileno (ostream), member.mode);
  #endif
+ #endif /* not __EMX__ */
    if (ferror (ostream) || fclose (ostream) != 0)
      error ("%s: I/O error", member.name);
  
***************
*** 776,782 ****
--- 815,825 ----
  {
    /* Open the existing archive file; if that fails, create an empty one.  */
  
+ #ifdef __EMX__
+   lock_indesc = open (archive, O_RDWR | O_BINARY, 0);
+ #else /* not __EMX__ */
    lock_indesc = open (archive, O_RDWR, 0);
+ #endif /* __EMX__ */
  
    if (lock_indesc < 0)
      {
***************
*** 784,790 ****
--- 827,837 ----
  
        if (!silent_create)
  	printf ("Creating archive file `%s'\n", archive);
+ #ifdef __EMX__
+       outdesc = open (archive, O_WRONLY | O_APPEND | O_CREAT | O_BINARY, 0666);
+ #else /* not __EMX__ */
        outdesc = open (archive, O_WRONLY | O_APPEND | O_CREAT, 0666);
+ #endif /* not __EMX__ */
        if (outdesc < 0)
  	pfatal_with_name (archive);
        mywrite (outdesc, ARMAG, SARMAG, archive);
***************
*** 792,798 ****
--- 839,849 ----
  
        /* Now we had better be able to open for update!  */
  
+ #ifdef __EMX__
+       lock_indesc = open (archive, O_RDWR | O_BINARY, 0);
+ #else /* not __EMX__ */
        lock_indesc = open (archive, O_RDWR, 0);
+ #endif /* not __EMX__ */
        if (lock_indesc < 0)
  	pfatal_with_name (archive);
      }
***************
*** 894,900 ****
--- 945,955 ----
  	 There can never be two invocations trying to do this at once,
  	 because of the lock made on the old archive file.  */
  
+ #ifdef __EMX__
+       outdesc = open (tempname, O_WRONLY | O_CREAT | O_BINARY, 0666);
+ #else /* not __EMX__ */
        outdesc = open (tempname, O_WRONLY | O_CREAT, 0666);
+ #endif /* not __EMX__ */
        if (outdesc < 0)
  	pfatal_with_name (tempname);
        outname = tempname;
***************
*** 904,910 ****
--- 959,969 ----
      {
        /* Fast-append to existing archive.  */
  
+ #ifdef __EMX__
+       outdesc = open (archive, O_WRONLY | O_APPEND | O_BINARY, 0);
+ #else /* not __EMX__ */
        outdesc = open (archive, O_WRONLY | O_APPEND, 0);
+ #endif /* not __EMX__ */
        if (outdesc < 0)
  	pfatal_with_name (archive);
        outname = archive;
***************
*** 992,1002 ****
--- 1051,1071 ----
  #endif
    close (outdesc);
  
+ #ifdef __EMX__
+   close_archive ();
+   if (!appendflag)
+     {
+     remove (archive);
+     if (rename (tempname, archive))
+       pfatal_with_name (tempname);
+     }
+ #else /* not __EMX__ */
    if (!appendflag)
      if (rename (tempname, archive))
        pfatal_with_name (tempname);
  
    close_archive ();
+ #endif /* not __EMX__ */
  }
  
  void
***************
*** 1005,1020 ****
--- 1074,1103 ----
       struct mapelt *mapelt;
  {
    unsigned int namelen;
+ #ifdef EMX
+   char *name;
+ #endif /* EMX */
  
    /* Zero the header, then store in the data as text.  */
    bzero ((char *) header, sizeof (*header));
  
+ #ifdef EMX
+   name = mapelt->info.name;
+   if (junk_paths) name = _getname (name);
+   strncpy (header->ar_name, name, sizeof (header->ar_name));
+   namelen = strlen (name);
+ #else /* not EMX */
    strncpy (header->ar_name, mapelt->info.name, sizeof (header->ar_name));
    namelen = strlen (mapelt->info.name);
+ #endif /* not EMX */
    if (namelen >= sizeof (header->ar_name))
      {
+ #ifdef EMX
+       if (name[namelen - 2] == '.' && name[namelen - 1] == 'o')
+ #else /* not EMX */
        if (mapelt->info.name[namelen - 2] == '.' &&
  	  mapelt->info.name[namelen - 1] == 'o')
+ #endif /* not EMX */
  	{
  	  header->ar_name[sizeof (header->ar_name) - 3] = '.';
  	  header->ar_name[sizeof (header->ar_name) - 2] = 'o';
***************
*** 1064,1070 ****
--- 1147,1157 ----
      }
    else
      {
+ #ifdef __EMX__
+       indesc = open (mapelt->info.name, O_BINARY, 0);
+ #else /* not __EMX__ */
        indesc = open (mapelt->info.name, 0, 0);
+ #endif /* not __EMX__ */
        if (indesc < 0)
  	{
  	  perror_with_name (mapelt->info.name);
***************
*** 1128,1134 ****
--- 1215,1225 ----
  make_tempname (name)
       char *name;
  {
+ #ifdef __EMX__
+   return concat (name, "", "$!");
+ #else /* not __EMX__ */
    return concat (name, "", "_supersede");
+ #endif /* not __EMX__ */
  }
  
  void
***************
*** 1380,1386 ****
--- 1471,1481 ----
        return;
      }
  
+ #ifdef __EMX__
+   arcstream = fopen (archive, "rb");
+ #else /* not __EMX__ */
    arcstream = fopen (archive, "r");
+ #endif /* not __EMX__ */
    if (!arcstream)
      fatal ("failure opening archive %s for the second time", archive);
    map = make_map (0);
***************
*** 1498,1509 ****
--- 1593,1618 ----
  	*syms_offset = N_SYMOFF (hdr);
  	*syms_size = hdr.a_syms;
  	*strs_offset = N_STROFF (hdr);
+ #ifdef __EMX__
+ 	if (hdr.a_syms == 0)
+ 	  *strs_size = sizeof *strs_size;
+ 	else
+ 	  {
+ 	    lseek (desc, N_STROFF (hdr) + offset, 0);
+ 	    if (read (desc, (char *) strs_size, sizeof *strs_size) != sizeof *strs_size)
+ 	      {
+ 		error_with_file ("failure reading string table size in ", mapelt);
+ 		return 0;
+ 	      }
+ 	  }
+ #else /* not __EMX__ */
  	lseek (desc, N_STROFF (hdr) + offset, 0);
  	if (read (desc, (char *) strs_size, sizeof *strs_size) != sizeof *strs_size)
  	  {
  	    error_with_file ("failure reading string table size in ", mapelt);
  	    return 0;
  	  }
+ #endif /* not __EMX__ */
  	return 1;
        }
    }
***************
*** 1584,1590 ****
--- 1693,1703 ----
      }
    else
      {
+ #ifdef __EMX__
+       indesc = open (mapelt->info.name, O_BINARY, 0);
+ #else /* not __EMX__ */
        indesc = open (mapelt->info.name, 0, 0);
+ #endif /* not __EMX__ */
        if (indesc < 0)
  	{
  	  perror_with_name (mapelt->info.name);
***************
*** 1603,1609 ****
--- 1716,1726 ----
    /* Number of symbol entries in the file.  */
    symcount = syms_size / sizeof (struct nlist);
    /* Allocate temporary space for the symbol entries.  */
+ #ifdef __EMX__
+   symbols = (struct nlist *) xmalloc (syms_size);
+ #else /* not __EMX__ */
    symbols = (struct nlist *) alloca (syms_size);
+ #endif /* not __EMX__ */
    /* Read in the symbols.  */
    lseek (indesc, syms_offset + offset, 0);
    if (read (indesc, (char *) symbols, syms_size) != syms_size)
***************
*** 1611,1616 ****
--- 1728,1736 ----
        error_with_file ("premature end of file in symbols of ", mapelt);
        if (mapelt->info.offset == 0)
  	(void) close (indesc);
+ #ifdef __EMX__
+       free (symbols);
+ #endif /* __EMX__ */
        return;
      }
  
***************
*** 1620,1625 ****
--- 1740,1748 ----
        error_with_file ("bad string table size in ", mapelt);
        if (mapelt->info.offset == 0)
  	(void) close (indesc);
+ #ifdef __EMX__
+       free (symbols);
+ #endif /* __EMX__ */
        return;
      }
    strs_size -= sizeof (strs_size);
***************
*** 1634,1639 ****
--- 1757,1765 ----
        error_with_file ("premature end of file in strings of ", mapelt);
        if (mapelt->info.offset == 0)
  	(void) close (indesc);
+ #ifdef __EMX__
+       free (symbols);
+ #endif /* __EMX__ */
        return;
      }
  
***************
*** 1658,1668 ****
--- 1784,1800 ----
  	  sprintf (buf, "ridiculous string offset %lu in symbol %u of ",
  		   stroff + sizeof (strs_size), i);
  	  error_with_file (buf, mapelt);
+ #ifdef __EMX__
+ 	  free (symbols);
+ #endif /* __EMX__ */
  	  return;
  	}
        mapelt->info.symdefs[i].s.name = symname;
        mapelt->info.string_size += strlen (symname) + 1;
      }
+ #ifdef __EMX__
+ free (symbols);
+ #endif /* __EMX__ */
  }
  
  /* Choose which symbol entries to mention in __.SYMDEF;
***************
*** 1906,1913 ****
--- 2038,2047 ----
  perror_with_name (name)
       char *name;
  {
+ #ifndef __EMX__
    extern int errno, sys_nerr;
    extern char *sys_errlist[];
+ #endif /* not __EMX__ */
    char *s;
  
    if (errno < sys_nerr)
***************
*** 1921,1928 ****
--- 2055,2064 ----
  pfatal_with_name (name)
       char *name;
  {
+ #ifndef __EMX__
    extern int errno, sys_nerr;
    extern char *sys_errlist[];
+ #endif /* not __EMX__ */
    char *s;
  
    if (errno < sys_nerr)
diff -c ./getopt.c c:\emx\gnu\binutils.old/getopt.c
*** ./getopt.c	Sat Jun 16 16:19:42 1990
--- c:\emx\gnu\binutils.old/getopt.c	Sun Nov 27 22:15:24 1994
***************
*** 1,3 ****
--- 1,5 ----
+ /* getopt.c -- changed for emx by Eberhard Mattes -- Nov 1994 */
+ 
  /* Getopt for GNU.
     Copyright (C) 1987, 1989 Free Software Foundation, Inc.
  
***************
*** 20,25 ****
--- 22,31 ----
  #else
  #define CONST
  #endif
+ 
+ #ifdef __EMX__
+ #include <strings.h>
+ #endif /* __EMX__ */
  
  /* This version of `getopt' appears to the caller like standard Unix `getopt'
     but it behaves differently for the user, since it allows the user
diff -c ./getopt1.c c:\emx\gnu\binutils.old/getopt1.c
*** ./getopt1.c	Mon Apr 16 18:51:20 1990
--- c:\emx\gnu\binutils.old/getopt1.c	Sun Nov 27 22:15:30 1994
***************
*** 1,3 ****
--- 1,5 ----
+ /* getopt1.c -- changed for emx by Eberhard Mattes -- Nov 1994 */
+ 
  /* Getopt for GNU.
     Copyright (C) 1987, 1989 Free Software Foundation, Inc.
  
***************
*** 15,20 ****
--- 17,26 ----
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  
+ #ifdef __EMX__
+ #include <strings.h>
+ #endif /* __EMX__ */
+ 
  #include "getopt.h"
  
  #ifdef __STDC__
diff -c ./ld.c c:\emx\gnu\binutils.old/ld.c
*** ./ld.c	Fri Jul  6 12:48:52 1990
--- c:\emx\gnu\binutils.old/ld.c	Fri Jul  5 20:33:58 1996
***************
*** 1,3 ****
--- 1,6 ----
+ /* ld.c -- changed for emx by Eberhard Mattes -- Jul 1996
+            changed for RSX by Rainer Schnitker -- Feb 1996 */
+ 
  /* Linker `ld' for GNU
     Copyright (C) 1988 Free Software Foundation, Inc.
  
***************
*** 20,25 ****
--- 23,33 ----
  
  #include <ar.h>
  #include <stdio.h>
+ #ifdef EMX /* host */
+ #include <stdlib.h>
+ #include <io.h>
+ #include <process.h>        /* for running emxbind */
+ #endif /* EMX */
  #include <sys/types.h>
  #include <sys/stat.h>
  #include <sys/file.h>
***************
*** 39,45 ****
--- 47,57 ----
  #ifdef COFF_ENCAPSULATE
  #include "a.out.encap.h"
  #else
+ #ifdef EMX /* host */
+ #include <a_out.h>
+ #else /* !EMX */
  #include <a.out.h>
+ #endif /* !EMX */
  #endif
  #endif
  
***************
*** 56,61 ****
--- 68,86 ----
  #include <sys/loader.h>
  #endif
  
+ #ifdef EMX /* fix bugs */
+ 
+ /* Fix two bugs in processing of set vectors:
+ 
+    o  The size of the set vector section is not correctly computed
+ 
+    o  References to set vectors can be wrong by up to sizeof (double) - 1
+       bytes because padding occurs at the wrong place */
+ 
+ #define FIXSETBUG
+ 
+ #endif /* EMX */
+ 
  #ifndef N_SET_MAGIC
  #define N_SET_MAGIC(exec, val)  ((exec).a_magic = val)
  #endif
***************
*** 493,498 ****
--- 518,527 ----
  #define N_SETV	0x1C		/* Pointer to set vector in data area.  */
  #endif				/* This is output from LD.  */
  
+ #ifdef EMX /* import */
+ #define N_IMP1  0x68            /* Import definition symbol */
+ #endif /* EMX */
+ 
  /* If a this type of symbol is encountered, its name is a warning
     message to print each time the symbol referenced by the next symbol
     table entry is referenced.
***************
*** 587,598 ****
--- 616,636 ----
  
  /* Demangler for C++.  */
  extern char *cplus_demangle ();
+ #ifdef EMX /* demangling */
+ #include "demangle.h"
+ static char *my_cplus_demangle ();
+ int demangle_options;
+ #endif /* EMX */
  
  /* Demangler function to use.  We unconditionally enable the C++ demangler
     because we assume any name it successfully demangles was probably produced
     by the C++ compiler.  Enabling it only if -lg++ was specified seems too
     much of a kludge.  */
+ #ifdef EMX /* demangling */
+ char *(*demangler)() = my_cplus_demangle;
+ #else /* !EMX */
  char *(*demangler)() = cplus_demangle;
+ #endif /* !EMX */
  
  /* Number of buckets in symbol hash table */
  #define	TABSIZE	1009
***************
*** 835,840 ****
--- 873,895 ----
  /* The name of the file to write; "a.out" by default.  */
  
  char *output_filename;
+ #ifdef EMX /* emxbind, relocatable */
+ char *exe_filename;
+ char *def_filename = NULL;
+ char *res_filename = NULL;
+ char *map_filename = NULL;
+ char *touch_filename = NULL;
+ int reloc_flag = 0;
+ int dll_flag = 0;
+ int exe_flag = 0;
+ int map_flag = 0;
+ int stack_size = 0;
+ int emxbind_strip = 0;
+ enum exe_bind_type
+ {
+   EMX_DEFAULT, RSXNT_WIN32, RSXNT_RSX, RSXNT_EMX
+ } rsxnt_linked = EMX_DEFAULT;
+ #endif /* EMX */
  
  /* What kind of output file to write.  */
  
***************
*** 910,919 ****
--- 965,983 ----
     written. */
  unsigned long *set_vectors;
  
+ #ifdef EMX /* relocatable */
+ int *set_reloc;
+ #endif /* EMX */
+ 
  /* Amount of cleared space to leave at the end of the text segment.  */
  
  int text_pad;
  
+ #ifdef FIXSETBUG
+ /* Amount of padding between data segment and set vectors. */
+ int set_sect_pad;
+ #endif /* FIXSETBUG */
+ 
  /* Amount of padding at end of data segment.  This has two parts:
     That which is before the bss segment, and that which overlaps
     with the bss segment.  */
***************
*** 979,985 ****
--- 1043,1053 ----
  #ifdef NON_NATIVE
    {"/usr/local/lib/gnu"};
  #else
+ #ifdef EMX /* host */
+   {"/emx/lib"};
+ #else /* !EMX */
    {"/lib", "/usr/lib", "/usr/local/lib"};
+ #endif /* !EMX */
  #endif
  #endif
  
***************
*** 1010,1017 ****
--- 1078,1087 ----
  #ifndef bcopy
  void bcopy (), bzero ();
  #endif
+ #ifndef EMX /* host */
  char *malloc (), *realloc ();
  void free ();
+ #endif /* !EMX */
  
  char *xmalloc ();
  char *xrealloc ();
***************
*** 1045,1056 ****
--- 1115,1132 ----
  char *concat ();
  char *get_file_name ();
  symbol *getsym (), *getsym_soft ();
+ #ifdef EMX /* emxbind */
+ void check_exe (void);
+ #endif /* EMX */
  
  int
  main (argc, argv)
       char **argv;
       int argc;
  {
+ #ifdef EMX /* host */
+   _response (&argc, &argv);
+ #endif /* EMX */
    page_size = getpagesize ();
    progname = argv[0];
  
***************
*** 1073,1078 ****
--- 1149,1157 ----
    text_reloc_size = 0;
    data_reloc_size = 0;
  
+ #ifdef FIXSETBUG
+   set_sect_pad = 0;
+ #endif /* FIXSETBUG */
    data_pad = 0;
    text_pad = 0;
  
***************
*** 1116,1121 ****
--- 1195,1204 ----
  
    decode_command (argc, argv);
  
+ #ifdef EMX /* emxbind */
+   check_exe ();
+ #endif /* EMX */
+ 
    /* Load symbols of all input files.
       Also search all libraries and decide which library members to load.  */
  
***************
*** 1172,1177 ****
--- 1255,1271 ----
    {"D", 1, 0, 'D'},
    {"M", 0, 0, 'M'},
    {"N", 0, 0, 'N'},
+ #ifdef EMX /* emxbind, relocatable, demangling */
+   {"R", 0, 0, 'R'},             /* Create relocatable executable */
+   {"Zexe", 0, 0, 135},          /* Create .exe file, touch `output file' */
+   {"Zstack", 1, 0, 136},        /* Set stack size */
+   {"Zmap", 2, 0, 137},          /* Create .map file */
+   {"Zno-demangle", 0, 0, 138},  /* Don't demangle symbols */
+   {"Zdemangle-proto", 0, 0, 139},  /* Demangle symbols complete */
+   {"Zwin32", 0, 0, 140},        /* Create GUI, CUI Win32 */
+   {"Zrsx32", 0, 0, 141},        /* Create Win32/DOS win32 base */
+   {"Zemx32", 0, 0, 142},        /* Create Win32/DOS emx base */
+ #endif /* EMX */
    {"S", 0, 0, 'S'},
    {"T", 1, 0, 'T'},
    {"Ttext", 1, 0, 'T'},
***************
*** 1331,1336 ****
--- 1425,1469 ----
  	  output_style = OUTPUT_WRITABLE_TEXT;
  	  break;
  
+ #ifdef EMX /* emxbind, relocatable, demangling */
+         case 135:               /* -Zexe */
+           exe_flag = 1;
+           break;
+ 
+         case 136:               /* -Zstack */
+ 	  stack_size = parse (optarg, "%i", "invalid argument to -Zstack");
+ 	  break;
+ 
+         case 137:               /* -Zmap */
+ 	  map_filename = optarg;
+ 	  map_flag = 1;
+ 	  break;
+ 
+         case 138:               /* -Zno-demangle */
+           demangler = 0;
+           break;
+ 
+         case 139:               /* -Zdemangle-proto */
+           demangle_options = DMGL_PARAMS | DMGL_ANSI;
+           break;
+ 
+         case 140:               /* -Zwin32: GUI,CUI Win32 */
+           rsxnt_linked = RSXNT_WIN32;
+           break;
+ 
+         case 141:               /* -Zrsx32: Win32/DOS win32 base */
+           rsxnt_linked = RSXNT_RSX;
+           break;
+ 
+         case 142:               /* -Zemx32: Win32/DOS emx base */
+           rsxnt_linked = RSXNT_EMX;
+           break;
+ 
+         case 'R':
+ 	  reloc_flag = 1;
+ 	  break;
+ #endif /* EMX */
+ 
  	case 'S':
  	  strip_symbols = STRIP_DEBUGGER;
  	  break;
***************
*** 1384,1389 ****
--- 1517,1541 ----
  	{
  	case 1:
  	  /* Non-option argument. */
+ #ifdef EMX /* emxbind */
+ 	  {
+ 	    char *ext = _getext (optarg);
+ 	    if (ext != NULL && stricmp (ext, ".def") == 0
+ 		&& def_filename == NULL)
+ 	      {
+ 		def_filename = optarg;
+ 		--number_of_files;
+ 		break;
+ 	      }
+             else if (ext != NULL && stricmp (ext, ".res") == 0
+                      && res_filename == NULL)
+ 	      {
+ 		res_filename = optarg;
+ 		--number_of_files;
+ 		break;
+ 	      }
+ 	  }
+ #endif /* EMX */
  	  p->filename = optarg;
  	  p->local_sym_name = optarg;
  	  p++;
***************
*** 1399,1405 ****
--- 1551,1561 ----
  	  break;
  
  	case 'l':
+ #ifdef EMX /* host */
+ 	  p->filename = concat ("", optarg, ".a");
+ #else /* !EMX */
  	  p->filename = concat ("lib", optarg, ".a");
+ #endif /* !EMX */
  	  p->local_sym_name = concat ("-l", optarg, "");
  	  p->search_dirs_flag = 1;
  	  p++;
***************
*** 1604,1610 ****
--- 1760,1770 ----
  	{
  	  register char *string
  	    = concat (search_dirs[i], "/", entry->filename);
+ #ifdef EMX /* host */
+ 	  desc = open (string, O_RDONLY|O_BINARY, 0);
+ #else /* !EMX */
  	  desc = open (string, O_RDONLY, 0);
+ #endif /* !EMX */
  	  if (desc > 0)
  	    {
  	      entry->filename = string;
***************
*** 1615,1621 ****
--- 1775,1785 ----
  	}
      }
    else
+ #ifdef EMX /* host */
+     desc = open (entry->filename, O_RDONLY|O_BINARY, 0);
+ #else /* !EMX */
      desc = open (entry->filename, O_RDONLY, 0);
+ #endif /* !EMX */
  
    if (desc > 0)
      {
***************
*** 2113,2118 ****
--- 2277,2286 ----
    for (p = entry->symbols; p < end; p++)
      {
        if (p->n_type == (N_SETV | N_EXT)) continue;
+ #ifdef EMX /* import, relocatable */
+       if (p->n_type == (N_IMP1 | N_EXT))
+         reloc_flag = 1;
+ #endif /* EMX */
        if (set_element_prefixes
  	  && set_element_prefixed_p (p->n_un.n_strx + entry->strings))
  	p->n_type += (N_SETA - N_ABS);
***************
*** 2348,2353 ****
--- 2516,2526 ----
  */
  #endif
  
+ #ifdef EMX /* import */
+         case N_IMP1:
+           reftype = "imported";
+           break;
+ #endif /* EMX */
  	default:
  	  reftype = "I don't know this type";
  	  break;
***************
*** 2738,2746 ****
--- 2911,2925 ----
  	  if (!sp) continue;
  
  	  if ((sp->referenced && !sp->defined)
+ #ifdef EMX
+ 	      || (sp->defined && sp->max_common_size
+ 		  && type != (N_INDR | N_EXT))
+ 	      )
+ #else /* not EMX */
  	      /* NB.  This needs to be changed so that, e.g., "int pipe;" won't import
  		 pipe() from the library.  But the bug fix kingdon made was wrong.  */
  	      || (sp->defined && sp->max_common_size))
+ #endif /* not EMX */
  	    {
  	      /* This is a symbol we are looking for.  It is either
  	         not yet defined or defined as a common.  */
***************
*** 2820,2825 ****
--- 2999,3014 ----
  
    initialize_data_start ();
  
+ #ifdef FIXSETBUG
+   /* Make sure the set vectors are aligned properly. */
+   {
+     int new_data_size = ((data_size + sizeof(unsigned long) - 1)
+                          & ~(sizeof(unsigned long)-1));
+ 
+     set_sect_pad += new_data_size - data_size;
+     data_size = new_data_size;
+   }
+ #else /* !FIXSETBUG */
    /* Make sure bss starts out aligned as much as anyone can want.  */
    {
      int new_data_size = (data_size + sizeof(double) - 1) & ~(sizeof(double)-1);
***************
*** 2827,2832 ****
--- 3016,3022 ----
      data_pad += new_data_size - data_size;
      data_size = new_data_size;
    }
+ #endif /* !FIXSETBUG */
  
    /* Set up the set element vector */
  
***************
*** 2836,2849 ****
--- 3026,3058 ----
           for each symbol for the length word at the beginning of the
  	 vector, plus a word for each symbol for a zero at the end of
  	 the vector (for incremental linking).  */
+ #ifdef FIXSETBUG
+       set_sect_size
+ 	= (set_symbol_count + 2 * set_vector_count) * sizeof (unsigned long);
+ #else /* !FIXSETBUG */
        set_sect_size
  	= (2 * set_symbol_count + set_vector_count) * sizeof (unsigned long);
+ #endif /* !FIXSETBUG */
        set_sect_start = data_start + data_size;
        data_size += set_sect_size;
        set_vectors = (unsigned long *) xmalloc (set_sect_size);
+ #ifdef EMX /* relocatable */
+       set_reloc = (int *) xmalloc (set_sect_size / sizeof (unsigned long)
+ 				   * sizeof (int));
+ #endif /* EMX */
        setv_fill_count = 0;
      }
  
+ #ifdef FIXSETBUG
+   /* Make sure bss starts out aligned as much as anyone can want.  */
+   {
+     int new_data_size = (data_size + sizeof(double) - 1) & ~(sizeof(double)-1);
+ 
+     data_pad += new_data_size - data_size;
+     data_size = new_data_size;
+   }
+ #endif /* FIXSETBUG */
+ 
    /* Compute start addresses of each file's sections and symbols.  */
  
    each_full_file (relocate_file_addresses, 0);
***************
*** 2888,2896 ****
--- 3097,3115 ----
  		      sp->multiply_defined = 1;
  		      multiple_def_count++;
  		    }
+ #ifdef EMX /* relocatable */
+ 		  set_reloc[setv_fill_count] = TYPE_OF_SET_ELEMENT (type);
+ 		  if ((type & ~N_EXT) != N_SETA)
+ 		    data_reloc_size += sizeof (struct relocation_info);
+ #endif /* EMX */
  		  set_vectors[setv_fill_count++] = p->n_value;
  		}
+ #ifdef EMX /* import */
+ 	      else if ((type & N_EXT) && type != (N_UNDF | N_EXT)
+                        && type != (N_IMP1 | N_EXT))
+ #else /* !EMX */
  	      else if ((type & N_EXT) && type != (N_UNDF | N_EXT))
+ #endif /* !EMX */
  		{
  		  /* non-common definition */
  		  if (defs++ && sp->value != p->n_value)
***************
*** 2952,2957 ****
--- 3171,3179 ----
  		= (sp->value - set_sect_start) / sizeof (unsigned long);
  	      unsigned long i, tmp;
  
+ #ifdef EMX /* relocatable */
+ 	      set_reloc[length_word_index] = N_ABS;
+ #endif /* EMX */
  	      set_vectors[length_word_index]
  		= setv_fill_count - 1 - length_word_index;
  
***************
*** 2960,2971 ****
--- 3182,3202 ----
  		   i < (setv_fill_count - length_word_index - 1) / 2 + 1;
  		   i++)
  		{
+ #ifdef EMX /* relocatable */
+ 		  tmp = set_reloc[length_word_index + i];
+ 		  set_reloc[length_word_index + i]
+ 		    = set_reloc[setv_fill_count - i];
+ 		  set_reloc[setv_fill_count - i] = (int)tmp;
+ #endif /* EMX */
  		  tmp = set_vectors[length_word_index + i];
  		  set_vectors[length_word_index + i]
  		    = set_vectors[setv_fill_count - i];
  		  set_vectors[setv_fill_count - i] = tmp;
  		}
  
+ #ifdef EMX /* relocatable */
+ 	      set_reloc[setv_fill_count] = N_ABS;
+ #endif /* EMX */
  	      set_vectors[setv_fill_count++] = 0;
  	    }
  	  if (sp->defined)
***************
*** 3877,3883 ****
--- 4108,4118 ----
  
    outheader.a_syms = nsyms * sizeof (struct nlist);
  
+ #ifdef EMX /* relocatable */
+   if (output_style == OUTPUT_RELOCATABLE || reloc_flag)
+ #else /* !EMX */
    if (output_style == OUTPUT_RELOCATABLE)
+ #endif /* !EMX */
      {
        outheader.a_trsize = text_reloc_size;
        outheader.a_drsize = data_reloc_size;
***************
*** 4501,4506 ****
--- 4736,4804 ----
    fatal ("unknown output file type (enum file_type)", (char *) 0);
  }
  
+ #ifdef EMX /* emxbind */
+ /* Parse output_filename and decide whether to create an exe file or not */
+ 
+ void check_exe (void)
+ {
+   char *ext, *tmp_dir;
+   size_t tmp_dir_len;
+ 
+   if (exe_flag)
+     {
+       ext = _getext (output_filename);
+       if (ext != NULL)
+         fatal ("The output file name must not have a suffix if -Zexe is used",
+                NULL);
+       touch_filename = output_filename;
+       exe_filename = concat (output_filename, ".exe", "");
+     }
+   else
+     {
+       ext = _getext2 (output_filename);
+       if (stricmp (ext, ".dll") == 0)
+         {
+           reloc_flag = 1; dll_flag = 1;
+         }
+       else if (stricmp (ext, ".exe") != 0)
+         {
+           exe_filename = NULL;
+           return;
+         }
+       exe_filename = output_filename;
+     }
+ 
+   /* Create a temporary a.out executable file. */
+ 
+   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);
+   output_filename = xmalloc (tmp_dir_len + 10);
+   memcpy (output_filename, tmp_dir, tmp_dir_len);
+   if (tmp_dir_len != 0 && strchr ("\\/:", tmp_dir[tmp_dir_len-1]) == NULL)
+     output_filename[tmp_dir_len++] = '\\';
+   strcpy (output_filename + tmp_dir_len, "ldXXXXXX");
+   if (mktemp (output_filename) == NULL)
+     fatal ("mktemp(\"%s\") failed", output_filename);
+ 
+   if (rsxnt_linked != EMX_DEFAULT && strip_symbols != STRIP_NONE) /* RSXNT */
+     {
+       strip_symbols = STRIP_NONE;
+       emxbind_strip = 1;
+     }
+   else if (strip_symbols == STRIP_ALL)
+     {
+       strip_symbols = STRIP_DEBUGGER;
+       emxbind_strip = 1;
+     }
+   unlink (exe_filename);
+   if (touch_filename != NULL)
+     unlink (touch_filename);
+ }
+ #endif /* EMX */
+ 
  /* Write the output file */
  
  void
***************
*** 4519,4525 ****
--- 4817,4827 ----
       the way Unix ld works; I'm going to consider it a feature.  */
    (void) unlink (output_filename);
    
+ #ifdef EMX /* host */
+   outdesc = open (output_filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
+ #else /* !EMX */
    outdesc = open (output_filename, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+ #endif /* !EMX */
    if (outdesc < 0) perror_name (output_filename);
  
    if (fstat (outdesc, &statbuf) < 0)
***************
*** 4527,4533 ****
--- 4829,4842 ----
  
    filemode = statbuf.st_mode;
  
+ #ifndef EMX /* host */
    chmod (output_filename, filemode & ~0111);
+ #endif /* !EMX */
+ 
+ #ifdef EMX /* relocatable */
+   if (reloc_flag)
+     global_indirect_count = 0;
+ #endif /* EMX */
  
    /* Calculate the offsets of the various pieces of the output file.  */
    compute_section_offsets ();
***************
*** 4537,4543 ****
--- 4846,4856 ----
    write_data ();
  
    /* Output the merged relocation info, if requested with `-r'.  */
+ #ifdef EMX /* relocatable */
+   if (output_style == OUTPUT_RELOCATABLE || reloc_flag)
+ #else /* !EMX */
    if (output_style == OUTPUT_RELOCATABLE)
+ #endif /* !EMX */
      write_rel ();
  
    /* Output the symbol table (both globals and locals).  */
***************
*** 4560,4565 ****
--- 4873,4993 ----
  
    if (chmod (output_filename, filemode | (0111 & ~mask)) == -1)
      perror_name (output_filename);
+ 
+ #ifdef EMX /* emxbind */
+   if (rsxnt_linked == EMX_DEFAULT && exe_filename != NULL)
+     {
+       char *nargv[11];
+       int i, saved_errno;
+ 
+       i = 0;
+       nargv[i++] = "emxbind";
+       nargv[i++] = "-bq";
+       if (emxbind_strip)
+         nargv[i++] = "-s";
+       if (def_filename != NULL)
+ 	{
+ 	  nargv[i] = alloca (strlen (def_filename) + 3);
+ 	  strcpy (nargv[i], "-d");
+ 	  strcat (nargv[i], def_filename);
+ 	  i++;
+ 	}
+       else if (dll_flag)
+ 	nargv[i++] = "-d";
+       if (stack_size != 0)
+ 	{
+ 	  nargv[i] = alloca (20);
+           sprintf (nargv[i], "-k0x%x", stack_size);
+ 	  i++;
+ 	}
+       if (map_flag)
+ 	{
+ 	  if (map_filename == NULL)
+ 	    {
+ 	      map_filename = alloca (strlen (output_filename) + 5);
+               strcpy (map_filename, exe_filename);
+ 	      _remext (map_filename);
+ 	      strcat (map_filename, ".map");
+ 	    }
+ 	  nargv[i] = alloca (strlen (map_filename) + 3);
+           strcpy (nargv[i], "-m");
+           strcat (nargv[i], map_filename);
+ 	  i++;
+ 	}
+       if (res_filename != NULL)
+ 	{
+ 	  nargv[i] = alloca (strlen (res_filename) + 3);
+ 	  strcpy (nargv[i], "-r");
+ 	  strcat (nargv[i], res_filename);
+ 	  i++;
+ 	}
+       nargv[i++] = "-o";
+       nargv[i++] = exe_filename;
+       nargv[i++] = output_filename;
+       nargv[i] = NULL;
+       i = spawnvp (P_WAIT, "emxbind", nargv);
+       saved_errno = errno; unlink (output_filename); errno = saved_errno;
+       if (i < 0)
+         perror_name ("emxbind");
+       else if (i != 0)
+         fatal ("emxbind failed\n", NULL);
+       if (chmod (exe_filename, filemode | (0111 & ~mask)) == -1)
+ 	perror_name (exe_filename);
+       if (touch_filename != NULL)
+         {
+           i = open (touch_filename,
+                     O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
+           if (i < 0)
+             perror_name (touch_filename);
+           close (i);
+         }
+     }
+   else if (exe_filename != NULL) /* RSXNT */
+     {
+       char *nargv[10];
+       int i, saved_errno;
+ 
+       i = 0;
+       nargv[i++] = "ntbind";
+       nargv[i++] = output_filename;
+       nargv[i++] = "-o";
+       nargv[i++] = exe_filename;
+       nargv[i++] = "-s";
+       if (rsxnt_linked == RSXNT_WIN32)
+         nargv[i++] = (emxbind_strip) ? "dosstub.dos" : "dosstub.dbg";
+       else
+         {
+         nargv[i++] = "dosstub.rsx";
+         if (emxbind_strip)
+           nargv[i++] = "-strip";
+         }
+       if (def_filename != NULL)
+ 	{
+           nargv[i++] = "-d";
+ 	  nargv[i] = alloca (strlen (def_filename) + 3);
+           strcpy(nargv[i], def_filename);
+           i++;
+ 	}
+       nargv[i] = NULL;
+ 
+       i = spawnvp (P_WAIT, "ntbind", nargv);
+       saved_errno = errno; unlink (output_filename); errno = saved_errno;
+       if (i < 0)
+         perror_name ("ntbind");
+       else if (i != 0)
+         fatal ("ntbind failed\n", NULL);
+       if (chmod (exe_filename, filemode | (0111 & ~mask)) == -1)
+ 	perror_name (exe_filename);
+       if (touch_filename != NULL)
+         {
+           i = open (touch_filename,
+                     O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
+           if (i < 0)
+             perror_name (touch_filename);
+           close (i);
+         }
+     }
+ #endif /* EMX */
  }
  
  void modify_location (), perform_relocation (), copy_text (), copy_data ();
***************
*** 4661,4667 ****
--- 5089,5099 ----
    /* Deal with relocation information however is appropriate */
  
    if (entry->textrel)  reloc = entry->textrel;
+ #ifdef EMX /* relocatable */
+   else if (output_style == OUTPUT_RELOCATABLE || reloc_flag)
+ #else /* !EMX */
    else if (output_style == OUTPUT_RELOCATABLE)
+ #endif /* !EMX */
      {
        read_file_relocation (entry);
        reloc = entry->textrel;
***************
*** 4712,4720 ****
--- 5144,5161 ----
    /* Write out the set element vectors.  See digest symbols for
       description of length of the set vector section.  */
  
+ #ifdef FIXSETBUG
+   padfile (set_sect_pad, outdesc);
+ #endif /* FIXSETBUG */
+ 
    if (set_vector_count)
+ #ifdef FIXSETBUG
+     mywrite (set_vectors, set_symbol_count + 2 * set_vector_count,
+ 	     sizeof (unsigned long), outdesc);
+ #else /* !FIXSETBUG */
      mywrite (set_vectors, 2 * set_symbol_count + set_vector_count,
  	     sizeof (unsigned long), outdesc);
+ #endif /* !FIXSETBUG */
  
    if (trace_files)
      fprintf (stderr, "\n");
***************
*** 4743,4749 ****
--- 5184,5194 ----
    bytes = (char *) alloca (entry->data_size);
  
    if (entry->datarel) reloc = entry->datarel;
+ #ifdef EMX /* relocatable */
+   else if (output_style == OUTPUT_RELOCATABLE || reloc_flag) /* Will need this again */
+ #else /* !EMX */
    else if (output_style == OUTPUT_RELOCATABLE)	/* Will need this again */
+ #endif /* !EMX */
      {
        read_file_relocation (entry);
        reloc = entry->datarel;
***************
*** 4978,4983 ****
--- 5423,5431 ----
  	    /* Leave room for the reference required by N_INDR, if
  	       necessary.  */
  	    if ((sp->defined & ~N_EXT) == N_INDR)
+ #ifdef EMX /* relocatable */
+ 	      if (!reloc_flag)
+ #endif /* EMX */
  	      count++;
  #endif
  	  }
***************
*** 5003,5008 ****
--- 5451,5484 ----
  
    lseek (outdesc, output_drel_offset, 0);
    each_full_file (copdatrel, 0);
+ #ifdef EMX /* relocatable */
+   if (reloc_flag)
+     {
+       int i;
+       int n = set_sect_size / sizeof (unsigned long);
+       struct relocation_info reloc;
+ 
+       memset (&reloc, 0, sizeof (reloc));
+       RELOC_PCREL_P (&reloc) = 0;
+       RELOC_TARGET_SIZE (&reloc) = 2;
+       RELOC_EXTERN_P (&reloc) = 0;
+       for (i = 0; i < n; ++i)
+ 	switch (set_reloc[i] & ~N_EXT)
+ 	  {
+ 	  case N_TEXT:
+ 	  case N_DATA:
+ 	    RELOC_SYMBOL (&reloc) = set_reloc[i] & ~N_EXT;
+ 	    RELOC_ADDRESS (&reloc)
+ 	      = set_sect_start + i * sizeof (unsigned long) - data_start;
+ 	    mywrite ((char *)&reloc, sizeof (reloc), 1, outdesc);
+ 	    break;
+ 	  case N_ABS:
+ 	    break;
+ 	  default:
+ 	    fatal ("N_SETB not supported", (char *)0);
+ 	  }
+     }
+ #endif /* EMX */
  
    if (trace_files)
      fprintf (stderr, "\n");
***************
*** 5040,5049 ****
--- 5516,5533 ----
  	  /* If the symbol is now defined, change the external relocation
  	     to an internal one.  */
  
+ #ifdef EMX /* import */
+ 	  if (symptr->defined && symptr->defined != (N_IMP1 | N_EXT))
+ #else /* !EMX */
  	  if (symptr->defined)
+ #endif /* !EMX */
  	    {
  	      RELOC_EXTERN_P(p) = 0;
  	      RELOC_SYMBOL(p) = (symptr->defined & ~N_EXT);
+ #ifdef EMX /* relocatable */
+ 	      if (RELOC_SYMBOL (p) == N_SETV)
+ 		RELOC_SYMBOL (p) = N_DATA;
+ #endif /* EMX */
  #ifdef RELOC_ADD_EXTRA
  	      /* If we aren't going to be adding in the value in
  	         memory on the next pass of the loader, then we need
***************
*** 5118,5125 ****
--- 5602,5616 ----
  	  symtype = symptr->defined & ~N_EXT;
  
  	  if (force_common_definition
+ #ifdef EMX /* relocatable */
+ 	      || reloc_flag
+ #endif /* EMX */
  	      || symtype == N_DATA || symtype == N_TEXT || symtype == N_ABS)
  	    {
+ #ifdef EMX /* relocatable */
+ 	      if (symtype == N_SETV)
+ 		symtype = N_DATA;
+ #endif /* EMX */
  	      RELOC_EXTERN_P(p) = 0;
  	      RELOC_SYMBOL(p) = symtype;
  	    }
***************
*** 5128,5137 ****
--- 5619,5632 ----
  	       after them.  */
  #ifndef NeXT
  	    RELOC_SYMBOL(p)
+ #ifdef EMX
+ 	      = (symptr
+ #else /* not EMX */
  	      = (((symbol *)
  		  (((struct nlist *)
  		    (((char *)entry->symbols) + symindex))
  		   ->n_un.n_name))
+ #endif /* not EMX */
  		 ->def_count
  		 + nsyms - defined_global_sym_count
  		 - undefined_global_sym_count
***************
*** 5206,5212 ****
--- 5701,5711 ----
    lseek (outdesc, output_strs_offset + output_strs_size, 0);
  
    if (!outstream)
+ #ifdef EMX /* host */
+     outstream = fdopen (outdesc, "wb");
+ #else /* !EMX */
      outstream = fdopen (outdesc, "w");
+ #endif /* !EMX */
  
    for (i = 0; i < strtab_index; i++)
      {
***************
*** 5425,5431 ****
--- 5924,5944 ----
        struct nlist nl;
  
        nl.n_type = N_TEXT;
+ #ifdef EMX /* fix GCC/ld/GDB problem */
+       {
+         char *tmp;
+         int len;
+ 
+         tmp = entry->local_sym_name;
+         len = strlen (tmp);
+         if (strncmp (tmp, "-l", 2) != 0
+             && (len < 2 || strcmp (tmp+len-2, ".o") != 0))
+           tmp = concat (tmp, ".o", "");   /* Needed by GDB */
+         nl.n_un.n_strx = assign_string_table_index (tmp);
+       }
+ #else /* !EMX */
        nl.n_un.n_strx = assign_string_table_index (entry->local_sym_name);
+ #endif /* !EMX */
        nl.n_value = entry->text_start_address;
        nl.n_desc = 0;
  #ifdef N_SECT
***************
*** 5783,5790 ****
--- 6296,6305 ----
  perror_name (name)
       char *name;
  {
+ #ifndef EMX /* host */
    extern int errno, sys_nerr;
    extern char *sys_errlist[];
+ #endif /* !EMX */
    char *s;
  
    if (errno < sys_nerr)
***************
*** 5801,5808 ****
--- 6316,6325 ----
  perror_file (entry)
       struct file_entry *entry;
  {
+ #ifndef EMX /* host */
    extern int errno, sys_nerr;
    extern char *sys_errlist[];
+ #endif /* !EMX */
    char *s;
  
    if (errno < sys_nerr)
***************
*** 5952,5954 ****
--- 6469,6482 ----
    return 8192;
  }
  #endif
+ 
+ #ifdef EMX /* demangling */
+ 
+ char *my_cplus_demangle (const char *mangled)
+ {
+   if (*mangled == '_')
+     ++mangled;
+   return cplus_demangle (mangled, demangle_options);
+ }
+ 
+ #endif /* EMX */
diff -c ./Makefile c:\emx\gnu\binutils.old/makefile
*** ./Makefile	Thu Jun 21 18:05:48 1990
--- c:\emx\gnu\binutils.old/makefile	Tue Sep  3 20:32:06 1996
***************
*** 19,29 ****
  # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  
  
! GNUCC = gcc -O
! bindir=/usr/local/bin
  
- # for BSD systems
- CFLAGS = -g
  # Don't add robotussin; it won't compile on BSD or GNU systems.
  # objdump is not here because it (at least used to) not compile
  # on most systems (trouble with N_DATADDR).  I've fixed some of
--- 19,34 ----
  # the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  
  
! GNUCC = gcc
! CC = gcc
! bindir=/emx/bin
! 
! .c.o:
! 	$(CC) $(CFLAGS) -c $*.c
! 
! # for emx (-g breaks ar!)
! CFLAGS = -O -I. -DEMX -Zsmall-conv
  
  # Don't add robotussin; it won't compile on BSD or GNU systems.
  # objdump is not here because it (at least used to) not compile
  # on most systems (trouble with N_DATADDR).  I've fixed some of
***************
*** 74,89 ****
  # rounds this up to a power of two (e.g. 5M becomes 8M), and so it might 
  # fail unnecessarily.  I've also seen some unix malloc's fail, even when
  # there is enough memory.  So use the new GNU malloc.
! MALLOC = $(archpfx)gmalloc.o
  
  GNU_GETOPT = $(archpfx)getopt.o
  GNU_GETOPT_LONG = $(archpfx)getopt.o $(archpfx)getopt1.o
  
  # C++ demangler
! CPLUS_DEM = $(archpfx)cplus-dem.o
  
  LIBS=$(ALLOCALIBS) $(SIGNAME)
  
  all: $(PROGS)
  
  $(archpfx)ld: $(archpfx)ld.o $(GNU_GETOPT_LONG) $(CPLUS_DEM)
--- 79,96 ----
  # rounds this up to a power of two (e.g. 5M becomes 8M), and so it might 
  # fail unnecessarily.  I've also seen some unix malloc's fail, even when
  # there is enough memory.  So use the new GNU malloc.
! # MALLOC = $(archpfx)gmalloc.o
  
  GNU_GETOPT = $(archpfx)getopt.o
  GNU_GETOPT_LONG = $(archpfx)getopt.o $(archpfx)getopt1.o
  
  # C++ demangler
! CPLUS_DEM = $(archpfx)cplus-de.o
  
  LIBS=$(ALLOCALIBS) $(SIGNAME)
  
+ bin4emx: ar ld size nm objdump strip
+ 
  all: $(PROGS)
  
  $(archpfx)ld: $(archpfx)ld.o $(GNU_GETOPT_LONG) $(CPLUS_DEM)
***************
*** 115,121 ****
  $(archpfx)ranlib.o: ranlib.c
  	$(CC) -c $(CFLAGS) -DAR_PROG=\"$(bindir)/ar\" ranlib.c $(OUTPUT_OPTION)
  
! $(archpfx)objdump: $(archpfx)objdump.o $(GNU_GETOPT_LONG) a.out.gnu.h
  	$(CC) $(CFLAGS) -o $(archpfx)objdump $(archpfx)objdump.o \
  		$(GNU_GETOPT_LONG) $(LIBS)
  
--- 122,128 ----
  $(archpfx)ranlib.o: ranlib.c
  	$(CC) -c $(CFLAGS) -DAR_PROG=\"$(bindir)/ar\" ranlib.c $(OUTPUT_OPTION)
  
! $(archpfx)objdump: $(archpfx)objdump.o $(GNU_GETOPT_LONG)
  	$(CC) $(CFLAGS) -o $(archpfx)objdump $(archpfx)objdump.o \
  		$(GNU_GETOPT_LONG) $(LIBS)
  
***************
*** 131,139 ****
  	libconvert usg-gnulib gnulib
  
  clean:
! 	-rm -f *.o core
! 	-rm -f $(archpfx)*.o
! 	-rm -f $(PROGS)
  
  dist: binutils.tar.Z
  
--- 138,150 ----
  	libconvert usg-gnulib gnulib
  
  clean:
! 	-del *.o
! 	-del ar
! 	-del ld
! 	-del nm
! 	-del objdump
! 	-del size
! 	-del strip
  
  dist: binutils.tar.Z
  
diff -c ./nm.c c:\emx\gnu\binutils.old/nm.c
*** ./nm.c	Tue Jun 12 03:47:34 1990
--- c:\emx\gnu\binutils.old/nm.c	Thu Oct 19 17:02:00 1995
***************
*** 1,3 ****
--- 1,5 ----
+ /* nm.c -- changed for emx by Eberhard Mattes -- Oct 1995 */
+ 
  /* Describe symbol table of a rel file.
     Copyright (C) 1986, 1988 Free Software Foundation, Inc.
  
***************
*** 30,36 ****
--- 32,42 ----
  #include "a.out.encap.h"
  #else
  /* On native BSD systems, use the system's own a.out.h.  */
+ #ifdef EMX
+ #include <a_out.h>
+ #else /* !EMX */
  #include <a.out.h>
+ #endif /* !EMX */
  #endif
  #endif
  
***************
*** 83,88 ****
--- 89,97 ----
  
  /* C++ demangler stuff.  */
  char *cplus_demangle ();
+ #ifdef EMX
+ extern int no_demangle;
+ #endif /* EMX */
  
  /* Print NAME on STREAM, demangling if necessary.  */
  void
***************
*** 90,96 ****
--- 99,110 ----
       FILE *stream;
       char *name;
  {
+ #ifdef EMX
+   char *demangled = (no_demangle ? NULL
+                      : cplus_demangle (*name == '_' ? name + 1 : name));
+ #else /* !EMX */
    char *demangled = cplus_demangle (name);
+ #endif /* !EMX */
    if (demangled == NULL)
      fputs (name, stream);
    else
***************
*** 210,215 ****
--- 224,232 ----
  int file_on_each_line;	/* print file name on each line.  */
  int debugger_syms;	/* print the debugger-only symbols.  */
  int print_symdefs;	/* describe the __.SYMDEF data in any archive file specified.  */
+ #ifdef EMX
+ int no_demangle;        /* do not demangle C++ names */
+ #endif /* !EMX */
  
  /* The __.SYMDEF member of an archive has the following format:
     1) A longword saying the size of the symdef data that follows
***************
*** 258,266 ****
--- 275,290 ----
        {"reverse",	0, &reverse_sort,	1},
        {"print-symdefs",	0, &print_symdefs,	1},
        {"undefined-only",0, &undefined_only,	1},
+ #ifdef EMX
+       {"no-demangle",   0, &no_demangle,	1},
+ #endif /* !EMX */
        {NULL, 0, NULL, 0}
      };
  
+ #ifdef EMX
+   _wildcard (&argc, &argv);
+   _response (&argc, &argv);
+ #endif /* !EMX */
    program_name = argv[0];
  
    number_of_files = 0;
***************
*** 272,279 ****
    file_on_each_line = 0;
    debugger_syms = 0;
    print_symdefs = 0;
! 
    while ((c = getopt_long (argc, argv, "agnoprsu", long_options, &ind)) != EOF)
      switch (c)
        {
        case 0:
--- 296,310 ----
    file_on_each_line = 0;
    debugger_syms = 0;
    print_symdefs = 0;
! #ifdef EMX
!   no_demangle = 0;
! #endif /* !EMX */
! 
! #ifdef EMX
!   while ((c = getopt_long (argc, argv, "agnoprsud", long_options, &ind)) != EOF)
! #else /* !EMX */
    while ((c = getopt_long (argc, argv, "agnoprsu", long_options, &ind)) != EOF)
+ #endif /* !EMX */
      switch (c)
        {
        case 0:
***************
*** 311,316 ****
--- 342,352 ----
  	undefined_only = 1;
  	break;
  
+ #ifdef EMX
+       case 'd':
+ 	no_demangle = 1;
+ 	break;
+ #endif /* !EMX */
        default:
  	fprintf (stderr, "\
  Usage: %s [-agnoprsu] [+all] [+extern-only] [+numeric-sort]\n\
***************
*** 351,358 ****
  {
    int len, desc, nchars;
    char armag[SARMAG];
! 
    desc = open (name, O_RDONLY, 0);
  
    if (desc < 0)
      {
--- 387,401 ----
  {
    int len, desc, nchars;
    char armag[SARMAG];
! #ifdef EMX
!   long hdr_pos;
! #endif /* !EMX */
! 
! #ifdef EMX
!   desc = open (name, O_RDONLY | O_BINARY, 0);
! #else /* !EMX */
    desc = open (name, O_RDONLY, 0);
+ #endif /* !EMX */
  
    if (desc < 0)
      {
***************
*** 363,373 ****
--- 406,423 ----
    input_name = name;
    input_member = 0;
  
+ #ifdef EMX
+   _seek_hdr (desc); hdr_pos = tell (desc);
+ #endif /* !EMX */
    nchars = read (desc, armag, SARMAG);
    if (nchars == SARMAG && !strncmp(armag, ARMAG, SARMAG))
      scan_library (desc);
    else
+ #ifdef EMX
+     do_one_rel_file (desc, hdr_pos);
+ #else /* !EMX */
      do_one_rel_file (desc, 0);
+ #endif /* !EMX */
  
    close (desc);
  }
***************
*** 483,488 ****
--- 533,545 ----
  	*syms_offset = N_SYMOFF(hdr);
  	*syms_size = hdr.a_syms;
  	*strs_offset = N_STROFF(hdr);
+ #ifdef EMX
+ 	if (hdr.a_syms == 0)
+ 	  {
+ 	    *strs_size = 0;
+ 	    return 1;
+ 	  }
+ #endif /* !EMX */
  	lseek(desc, N_STROFF(hdr) + offset, 0);
  	if (read (desc, (char *) strs_size, sizeof *strs_size) != sizeof *strs_size)
  	  {
diff -c ./objdump.c c:\emx\gnu\binutils.old/objdump.c
*** ./objdump.c	Sat Dec 30 01:16:06 1989
--- c:\emx\gnu\binutils.old/objdump.c	Thu Oct 19 17:01:58 1995
***************
*** 1,3 ****
--- 1,5 ----
+ /* objdump.c -- changed for emx by Eberhard Mattes -- Oct 1995 */
+ 
  /* objdump -- dump information about an object file.
     Copyright (C) 1988, Free Software Foundation, Inc.
  
***************
*** 22,42 ****
   * refer to the manual page dump(1) in the system 5 program's reference manual
   */
  #include <stdio.h>
  #include "getopt.h"
  
  #ifndef COFF_ENCAPSULATE
! #include <a.out.h>
! /* Tell a.out.gnu.h not to try to redefine some things.  */
! #define __STRUCT_EXEC_OVERRIDE__
! #define N_NLIST_DECLARED
! #define N_RELOCATION_INFO_DECLARED
! #define N_MAGIC(exec) ((exec).a_magic)
! #include "a.out.gnu.h"
  #else
  #include "a.out.encap.h"
  #endif
  
! char *malloc();
  char *xmalloc();
  int nsyms;
  struct nlist *symtbl;
--- 24,41 ----
   * refer to the manual page dump(1) in the system 5 program's reference manual
   */
  #include <stdio.h>
+ #include <stdlib.h>
  #include "getopt.h"
  
  #ifndef COFF_ENCAPSULATE
! #include <a_out.h>
  #else
  #include "a.out.encap.h"
  #endif
  
! #define HEADER_SEEK(f) _fseek_hdr(f)
! static long hdr_pos;
! 
  char *xmalloc();
  int nsyms;
  struct nlist *symtbl;
***************
*** 58,78 ****
  
  	symtbl = (struct nlist *)xmalloc (nsyms * sizeof (struct nlist));
  
! 	fseek (f, N_STROFF(*execp), 0);
  	if (fread ((char *)&strsize, sizeof strsize, 1, f) != 1) {
  		fprintf (stderr, "%s: can not read string table size\n",
  			 program_name);
  		exit (1);
  	}
  	strtbl = xmalloc (strsize);
! 	fseek (f, N_STROFF (*execp), 0);
  	if (fread (strtbl, 1, strsize, f) != strsize) {
  		fprintf (stderr, "%s: error reading string table\n",
  			 program_name);
  		exit (1);
  	}
  
! 	fseek (f, N_SYMOFF (*execp), 0);
  	if (fread ((char *)symtbl, sizeof (struct nlist), nsyms, f) != nsyms) {
  		fprintf (stderr, "%s: error reading symbol table\n",
  			 program_name);
--- 57,77 ----
  
  	symtbl = (struct nlist *)xmalloc (nsyms * sizeof (struct nlist));
  
!     fseek (f, N_STROFF(*execp) + hdr_pos, 0);
  	if (fread ((char *)&strsize, sizeof strsize, 1, f) != 1) {
  		fprintf (stderr, "%s: can not read string table size\n",
  			 program_name);
  		exit (1);
  	}
  	strtbl = xmalloc (strsize);
!     fseek (f, N_STROFF (*execp) + hdr_pos, 0);
  	if (fread (strtbl, 1, strsize, f) != strsize) {
  		fprintf (stderr, "%s: error reading string table\n",
  			 program_name);
  		exit (1);
  	}
  
!     fseek (f, N_SYMOFF (*execp) + hdr_pos, 0);
  	if (fread ((char *)symtbl, sizeof (struct nlist), nsyms, f) != nsyms) {
  		fprintf (stderr, "%s: error reading symbol table\n",
  			 program_name);
***************
*** 133,138 ****
--- 132,139 ----
  	    {NULL, 0, NULL, 0}
  	  };
  
+ 	_wildcard (&argc, &argv);
+ 	_response (&argc, &argv);
  	page_size = getpagesize ();
  
  	program_name = argv[0];
***************
*** 164,170 ****
  	FILE *f;
  	struct exec exec;
  	printf ("%s:\n", name);
! 	f = fopen (name, "r");
  	if (f == NULL) {
  		fprintf (stderr, "%s: can not open ", program_name);
  		perror (name);
--- 165,171 ----
  	FILE *f;
  	struct exec exec;
  	printf ("%s:\n", name);
!         f = fopen (name, "rb");
  	if (f == NULL) {
  		fprintf (stderr, "%s: can not open ", program_name);
  		perror (name);
***************
*** 173,178 ****
--- 174,180 ----
  #ifdef HEADER_SEEK
  	HEADER_SEEK (f);
  #endif
+ 	hdr_pos = ftell (f);
  	if (fread ((char *)&exec, sizeof exec, 1, f) != 1) {
  		fprintf (stderr, "%s: can not read header for %s\n",
  			 program_name, name);
***************
*** 207,215 ****
  	int x;
  
  #if defined (__GNU_EXEC_MACROS__) && !defined (__STRUCT_EXEC_OVERRIDE__)
! 	printf ("magic: 0x%x (%o)", N_MAGIC(*execp), N_MAGIC(*execp));
! 	printf ("machine type: %d", N_MACHTYPE(*execp));
! 	printf ("flags: 0x%x", N_FLAGS(*execp));
  #else /* non-gnu struct exec.  */
  	printf ("magic: 0x%x (%o) ", execp->a_magic, execp->a_magic);
  #endif /* non-gnu struct exec.  */
--- 209,217 ----
  	int x;
  
  #if defined (__GNU_EXEC_MACROS__) && !defined (__STRUCT_EXEC_OVERRIDE__)
! 	printf ("magic: 0x%x (%o) ", N_MAGIC(*execp), N_MAGIC(*execp));
! 	printf ("machine type: %d ", N_MACHTYPE(*execp));
! 	printf ("flags: 0x%x ", N_FLAGS(*execp));
  #else /* non-gnu struct exec.  */
  	printf ("magic: 0x%x (%o) ", execp->a_magic, execp->a_magic);
  #endif /* non-gnu struct exec.  */
***************
*** 269,279 ****
  	read_symbols (execp, f);
  	if (execp->a_trsize) {
  		printf ("text reloc\n");
! 		dump_reloc1 (execp, f, N_TRELOFF (*execp), execp->a_trsize);
  	}
  	if (execp->a_drsize) {
  		printf ("data reloc\n");
! 		dump_reloc1 (execp, f, N_DRELOFF (*execp), execp->a_drsize);
  	}
  }
  
--- 271,281 ----
  	read_symbols (execp, f);
  	if (execp->a_trsize) {
  		printf ("text reloc\n");
!         dump_reloc1 (execp, f, N_TRELOFF (*execp) + hdr_pos, execp->a_trsize);
  	}
  	if (execp->a_drsize) {
  		printf ("data reloc\n");
!         dump_reloc1 (execp, f, N_DRELOFF (*execp) + hdr_pos, execp->a_drsize);
  	}
  }
  
diff -c ./size.c c:\emx\gnu\binutils.old/size.c
*** ./size.c	Tue Jun 12 03:56:50 1990
--- c:\emx\gnu\binutils.old/size.c	Sun May  3 11:42:22 1992
***************
*** 1,3 ****
--- 1,5 ----
+ /* size.c -- changed for emx by Eberhard Mattes -- Jan 1992 */
+ 
  /* Size of rel file utility (`size') for GNU.
     Copyright (C) 1986 Free Software Foundation, Inc.
  
***************
*** 16,21 ****
--- 18,24 ----
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  
  #include <stdio.h>
+ #include <stdlib.h>
  #include <ar.h>
  #include <sys/types.h>
  #include <sys/file.h>
***************
*** 29,35 ****
  #include "a.out.encap.h"
  #else
  /* On native BSD systems, use the system's own a.out.h.  */
! #include <a.out.h>
  #endif
  #endif
  
--- 32,38 ----
  #include "a.out.encap.h"
  #else
  /* On native BSD systems, use the system's own a.out.h.  */
! #include <a_out.h>
  #endif
  #endif
  
***************
*** 61,67 ****
  
  int member_offset;
  
- char *malloc ();
  
  void do_one_file (), do_one_rel_file ();
  char *xmalloc ();
--- 64,69 ----
***************
*** 73,78 ****
--- 75,81 ----
  {
    int i;
  
+   _wildcard (&argc, &argv);
    number_of_files = argc - 1;
  
    printf ("text\tdata\tbss\tdec\thex\n");
***************
*** 106,113 ****
  {
    int len, desc;
    char armag[SARMAG];
  
!   desc = open (name, O_RDONLY, 0);
  
    if (desc < 0)
      {
--- 109,117 ----
  {
    int len, desc;
    char armag[SARMAG];
+   long hdr_pos;      /* emx */
  
!   desc = open (name, O_RDONLY | O_BINARY, 0);
  
    if (desc < 0)
      {
***************
*** 118,125 ****
    input_name = name;
    input_member = 0;
  
    if (SARMAG != read (desc, armag, SARMAG) || strncmp (armag, ARMAG, SARMAG))
!     do_one_rel_file (desc, 0L);
    else
      scan_library (desc);
  
--- 122,131 ----
    input_name = name;
    input_member = 0;
  
+   _seek_hdr (desc); hdr_pos = tell (desc);
+ 
    if (SARMAG != read (desc, armag, SARMAG) || strncmp (armag, ARMAG, SARMAG))
!     do_one_rel_file (desc, hdr_pos);
    else
      scan_library (desc);
  
***************
*** 345,352 ****
  perror_name (name)
       char *name;
  {
-   extern int errno, sys_nerr;
-   extern char *sys_errlist[];
    char *s;
  
    if (errno < sys_nerr)
--- 351,356 ----
diff -c ./strip.c c:\emx\gnu\binutils.old/strip.c
*** ./strip.c	Mon Jun 11 22:40:00 1990
--- c:\emx\gnu\binutils.old/strip.c	Mon Oct  3 23:32:10 1994
***************
*** 1,3 ****
--- 1,5 ----
+ /* strip.c -- changed for emx by Eberhard Mattes -- Oct 1994 */
+ 
  /* strip certain symbols from a rel file.
     Copyright (C) 1986 Free Software Foundation, Inc.
  
***************
*** 16,21 ****
--- 18,24 ----
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  
  #include <stdio.h>
+ #include <stdlib.h>
  #include <sys/types.h>
  #include <sys/file.h>
  #include <sys/stat.h>
***************
*** 38,44 ****
  #include "a.out.encap.h"
  #else
  /* On native BSD systems, use the system's own a.out.h.  */
! #include <a.out.h>
  #endif
  #endif
  
--- 41,47 ----
  #include "a.out.encap.h"
  #else
  /* On native BSD systems, use the system's own a.out.h.  */
! #include <a_out.h>
  #endif
  #endif
  
***************
*** 138,145 ****
  /* 1 => discard locals starting with L; 2 => discard all locals */
  int discard_locals;
  
- char *malloc ();
- 
  void strip_file ();
  int file_open ();
  void rewrite_file_symbols(), file_close();
--- 141,146 ----
***************
*** 169,174 ****
--- 170,176 ----
    struct file_entry *p;
    int i;
  
+   _wildcard (&argc, &argv);
    strip_symbols = 0;   /* default is to strip everything.  */
    discard_locals = 0;
  
***************
*** 224,239 ****
    exit (0);
  }
  
- int delayed_signal;
- 
- void
- delay_signal (signo)
-      int signo;
- {
-   delayed_signal = signo;
-   signal (signo, delay_signal);
- }
- 
  /* process one input file */
  
  void
--- 226,231 ----
***************
*** 262,275 ****
      }
  
    /* Effectively defer handling of asynchronous kill signals.  */
!   delayed_signal = 0;
!   if (signal (SIGINT, SIG_IGN) != SIG_IGN)
!     sigint_handled = 1, signal (SIGINT, delay_signal);
!   if (signal (SIGHUP, SIG_IGN) != SIG_IGN)
!     sighup_handled = 1, signal (SIGHUP, delay_signal);
!   if (signal (SIGTERM, SIG_IGN) != SIG_IGN)
!     sigterm_handled = 1, signal (SIGTERM, delay_signal);
! 
    /* Change the file.  */
  
    rewrite_file_symbols (entry);
--- 254,260 ----
      }
  
    /* Effectively defer handling of asynchronous kill signals.  */
!   /* -- deleted for emx */
    /* Change the file.  */
  
    rewrite_file_symbols (entry);
***************
*** 279,294 ****
    file_close ();
  
    /* Effectively undefer handling.  */
!   if (sigint_handled)
!     signal (SIGINT, SIG_DFL);
!   if (sighup_handled)
!     signal (SIGHUP, SIG_DFL);
!   if (sigterm_handled)
!     signal (SIGTERM, SIG_DFL);
! 
!   /* Handle any signal that came in while they were deferred.  */
!   if (delayed_signal)
!     kill (getpid (), delayed_signal);
  }
  
  /** Convenient functions for operating on one or all files being processed.  */
--- 264,270 ----
    file_close ();
  
    /* Effectively undefer handling.  */
!   /* -- deleted for emx */
  }
  
  /** Convenient functions for operating on one or all files being processed.  */
***************
*** 314,320 ****
    int desc;
    int len, magicnum;
  
!   desc = open (entry->filename, O_RDWR, 0);
  
    if (desc > 0)
      {
--- 290,296 ----
    int desc;
    int len, magicnum;
  
!   desc = open (entry->filename, O_RDWR | O_BINARY, 0);
  
    if (desc > 0)
      {
***************
*** 405,416 ****
  	entry->syms_offset = N_SYMOFF(hdr);
  	entry->syms_size = hdr.a_syms;
  	entry->strs_offset = N_STROFF(hdr);
! 	lseek(desc, entry->strs_offset, 0);
! 	if (read (desc, (char *) &entry->strs_size, sizeof entry->strs_size)
! 	    != sizeof entry->strs_size)
  	  {
! 	    error_with_file ("cannot read string table size", entry);
! 	    return -1;
  	  }
  	return 0;
        }
--- 381,397 ----
  	entry->syms_offset = N_SYMOFF(hdr);
  	entry->syms_size = hdr.a_syms;
  	entry->strs_offset = N_STROFF(hdr);
! 	if (hdr.a_syms == 0)
! 	  entry->strs_size = 0;
! 	else
  	  {
! 	    lseek(desc, entry->strs_offset, 0);
! 	    if (read (desc, (char *) &entry->strs_size, sizeof entry->strs_size)
! 		!= sizeof entry->strs_size)
! 	      {
! 		error_with_file ("cannot read string table size", entry);
! 		return -1;
! 	      }
  	  }
  	return 0;
        }
***************
*** 845,852 ****
  perror_name (name)
       char *name;
  {
-   extern int errno, sys_nerr;
-   extern char *sys_errlist[];
    char *s;
  
    if (errno < sys_nerr)
--- 826,831 ----
***************
*** 862,870 ****
  perror_file (entry)
       struct file_entry *entry;
  {
!   extern int errno, sys_nerr;
!   extern char *sys_errlist[];
!   char *s;
  
    if (errno < sys_nerr)
      s = sys_errlist[errno];
--- 841,847 ----
  perror_file (entry)
       struct file_entry *entry;
  {
!   const char *s;
  
    if (errno < sys_nerr)
      s = sys_errlist[errno];
***************
*** 876,882 ****
  /* Report an error.   STRING is printed, and the filename of ENTRY.  */
  
  error_with_file (string, entry, arg1, arg2)
!      char *string;
       struct file_entry *entry;
       int arg1, arg2;
  {
--- 853,859 ----
  /* Report an error.   STRING is printed, and the filename of ENTRY.  */
  
  error_with_file (string, entry, arg1, arg2)
!      const char *string;
       struct file_entry *entry;
       int arg1, arg2;
  {
