Subject: N_GETMAGIC
To: None <current-users@netbsd.org>
From: Sean Doran <smd@ebone.net>
List: current-users
Date: 11/15/1998 06:13:18
This illustrates the problem:

: crasse.smd.ebone.net ; cc -v
Using builtin specs.
gcc version egcs-2.91.58 19981101 (egcs-1.1.1 pre-release)
: crasse.smd.ebone.net ; cc -o y y.c
: crasse.smd.ebone.net ; ./y
QMAGIC: 204, ZMAGIC: 267, CURRENT_N_GETMAGIC: -2138701824, N_GETMAGIC: 267

also has a problem with older egcs

: sean.ebone.net ; cc -v
Using builtin specs.
gcc version egcs-2.91.57 19980901 (egcs-1.1 release)
: sean.ebone.net ; cc -o y y.c
: sean.ebone.net ; ./y
QMAGIC: 204, ZMAGIC: 267, CURRENT_N_GETMAGIC: -2138701824, N_GETMAGIC: 267

I don't have a non-egcs -386 around to play with just this moment. :(

	Sean.

- --
#include <stdio.h>
/* pre 19981113 */
#include <sys/exec_aout.h>

#define CURRENT_N_GETMAGIC(ex) \
    ((((ex).a_midmag)&0xffff0000) ? \
    (ntohl((u_int32_t)(((ex).a_midmag))&0xffff)) : ((ex).a_midmag))


main() 
{
struct exec hdr;
int fd;

	fd=open("/usr/bin/make", 0, 0);
	if(fd==-1) { perror("no /usr/bin/make?"); exit(1); }

	if(read(fd, &hdr, sizeof hdr) < sizeof hdr) {
		perror("error reading /usr/bin/make"); exit(1); 
        }

	printf("QMAGIC: %d, ZMAGIC: %d, CURRENT_N_GETMAGIC: %d, N_GETMAGIC: %d\n",
		QMAGIC, ZMAGIC, CURRENT_N_GETMAGIC(hdr), N_GETMAGIC(hdr));
}