Subject: Re: Unusual N_TXTADDR() ...
To: Andrew Cagney <cagney@highland.oz.au>
From: Theo de Raadt <deraadt@fsa.ca>
List: tech-kern
Date: 06/16/1994 07:13:17
> In /usr/include/a.out.h N_TXT_ADDR is defined to be:
> 
>     /* Address of the bottom of the text segment. */
>     #define N_TXTADDR(ex)   (N_GETMAGIC2(ex) == (ZMAGIC|0x10000) ? 0 :
>     __LDPGSZ)
> 
> Or to translate (?) it:
> 
>     ZMAGIC files (pageable) have N_TXTADDR of 0 while all others
>     (including .o files with OMAGIC) have a N_TXTADDR of __LDPGSZ (4096)

Er, not quite.

N_GETMAGIC2() or's 0x10000 into the standard magic number iff it finds
a zero'd MID field in the a.out a_midmag field. In that case we are
not looking at a modern NetBSD executable -- we are looking at a
386BSD executable!

All modern NetBSD executables have a non-zero MID field, and map at
__LDPGSZ, for all three cases: ZMAGIC, NMAGIC, or OMAGIC.

386BSD executables had the MID field set to zero. They were always
ZMAGIC, and their text segment mapped at address 0.

If we didn't require `size' and other a.out handling tools to work on
386BSD executables, we could probably remove this old cruft.  I'd
probably prefer if it was just ripped out, it's confusing and I just
spent 4 minutes staring at it trying to figure out why something
wasn't a bug.

------------------------------------------------------------------------------