Mail Archives: djgpp/1993/07/20/18:57:44
Here are the patches necessary to produce an aout2exe that works on Unix.
This is useful if you are in a cross compiler environment. Apply with:
patch -p0 < this-file
Make sure you are in the djgpp-110/go32 directory, i.e. the one with the
source code for go32. I believe that the changes I have made will not break
a DOS compile. It is still necessary to grab the stub.exe file from the
standard distribution. Use bin2byte to generate stubbytes.h. (Thanks for
hitting me in the side of the head DJ... :-)
diff -c ./aout2exe.c unix/aout2exe.c
*** ./aout2exe.c Sun Jul 18 19:43:48 1993
--- unix/aout2exe.c Tue Jul 20 10:36:33 1993
***************
*** 1,7 ****
--- 1,9 ----
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
+ #ifndef __unix__
#include <alloc.h>
+ #endif
#include <string.h>
#include "stubbytes.h"
***************
*** 13,18 ****
--- 15,41 ----
aout2exe(argv[i]);
}
+ #ifdef __unix__
+ int must_swap()
+ {
+ static short swaptest = 1;
+ return((*(char *)&swaptest) ? 0 : 1);
+ }
+
+ short swap_short(short n)
+ {
+ char *addr = (char *)&n;
+ char t = addr[0];
+ addr[0] = addr[1];
+ addr[1] = t;
+ return(n);
+ }
+ #endif
+
+ #ifndef O_BINARY
+ # define O_BINARY 0
+ #endif
+
aout2exe(char *fname)
{
int ifile;
***************
*** 47,53 ****
--- 70,80 ----
return;
}
hsize = (sizeof(stub_bytes) + 511) & ~511;
+ #ifdef __unix__
+ ((short *)stub_bytes)[2] = (must_swap()) ? swap_short(hsize / 512) : hsize / 512;
+ #else
((short *)stub_bytes)[2] = hsize / 512;
+ #endif
((short *)stub_bytes)[1] = 0;
write(ofile, stub_bytes, hsize);
diff -c ./bin2byte.c unix/bin2byte.c
*** ./bin2byte.c Sun Jul 18 19:43:48 1993
--- unix/bin2byte.c Tue Jul 20 10:34:48 1993
***************
*** 2,7 ****
--- 2,11 ----
#include <fcntl.h>
#include <sys/stat.h>
+ #ifndef O_BINARY
+ # define O_BINARY 0
+ #endif
+
main(int argc, char **argv)
{
int f = open(argv[1], O_RDONLY|O_BINARY);
--
Ken Fox (fox AT pt0204 DOT pto DOT ford DOT com) | My opinions or statements do not
| represent those of, nor are endorsed by,
| Ford Motor Company.
CAD/CAM Technology Section |
CAD/CAM/CAE Process Integration | "Is this some sort of trick question
Ford Motor Company | or what?" -- Calvin
- Raw text -