Core -> a.out conversion program

utzoo!decvax!ucbvax!mhtsa!harpo!floyd!houxi!ihnss!ihps3!stolaf!borman utzoo!decvax!ucbvax!mhtsa!harpo!floyd!houxi!ihnss!ihps3!stolaf!borman
Tue Feb 23 19:07:10 AEST 1982


I just got undump to work on our system. We're running a fairly standard
version of V7 on an 11/70. Three things that are on interest to everyone
are 1) change the declarations of txtcnt and datacnt to unsigned.  Failure
to do so cause the program to blow up on large programs.  2) in copy_data(),
a click to bit conversion should be done on u.u_tsize before adding it
to datacnt.  3) type cast long onto the second arg. of the fseeks. The
specific changes I made are as follows (sys/sto.h contains #define macros
for our current version on UNIX*)
					Dave Borman
					!ihnss!ihuxl!stolaf!borman

diff undump.orig undump.c

14a15,16
> #include <sys/sto.h>
> #include <sys/types.h>
18c20
< #include <stat.h>
---
> #include <sys/stat.h>
21a24,30
> #define	N_BADMAG(x)	( (x.a_magic != A_MAGIC1) && (x.a_magic != A_MAGIC2) &&\
> 			  (x.a_magic != A_MAGIC3) && (x.a_magic != A_MAGIC4) &&\
> 			  (x.a_magic != A_MAGIC5) && (x.a_magic != A_MAGIC6) )
> 
> #define N_TXTOFF(hdr)	(sizeof hdr)
> #define	OMAGIC	A_MAGIC1	/* Magic number of Writeable text file */
> #define UPAGES	020
95a105
> 
97,99c107,112
< 	hdr.a_text != u.u_exdata.ux_tsize ||
< 	hdr.a_data != u.u_exdata.ux_dsize ||
< 	hdr.a_entry != u.u_exdata.ux_entloc)
---
>       ((hdr.a_magic != OMAGIC) &&
> 	     (hdr.a_text != u.u_exdata.ux_tsize ||
> 	      hdr.a_data != u.u_exdata.ux_dsize)) ||
>       ((hdr.a_magic == OMAGIC) &&
> 	    (hdr.a_data + hdr.a_text != u.u_exdata.ux_dsize)) ||
>       hdr.a_entry != u.u_exdata.ux_entloc)
123c136
<     int txtcnt = hdr.a_text;
---
>     unsigned txtcnt = hdr.a_text;
125,126c138,139
<     fseek(new, N_TXTOFF(hdr), 0);
<     fseek(a_out, N_TXTOFF(hdr), 0);
---
>     fseek(new, (long)N_TXTOFF(hdr), 0);
>     fseek(a_out, (long)N_TXTOFF(hdr), 0);
130c143
< 	fseek(a_out, hdr.a_text, 1);	/* skip over text */
---
> 	fseek(a_out, (long)hdr.a_text, 1);	/* skip over text */
169c182
<     int datacnt = ctob(u.u_dsize);
---
>     unsigned datacnt = ctob(u.u_dsize);
172,173c185,186
< 	datacnt += u.u_tsize;
<     fseek(core, ctob(UPAGES), 0);
---
> 	datacnt += ctob(u.u_tsize);
>     fseek(core, (long)ctob(UPAGES), 0);
212c225
<     fseek(a_out, ohdr.a_data, 1);	/* skip over data segment */
---
>     fseek(a_out, (long)ohdr.a_data, 1);	/* skip over data segment */


--------------------------
*UNIX is a Trademark of Bell Laboratories.



More information about the Comp.unix.wizards mailing list