Subject: Unusual N_TXTADDR() ...
To: None <tech-kern@sun-lamp.cs.berkeley.edu, tech-ports@sun-lamp.cs.berkeley.edu>
From: Andrew Cagney <cagney@highland.oz.au>
List: tech-kern
Date: 06/16/1994 18:36:14
Hi,

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)

The consequence of this is that symbol offsets in object files are all
4096 bytes short of the TXT addresses they refer to.  Looking in the
source code for LD one finds:

    i386/md.h:#define N_ADJUST(ex)          (((ex).a_entry < PAGSIZ) ?
    -PAGSIZ : 0)
    i386/md.h:#define TEXT_START(ex)        (N_TXTADDR(ex) + N_ADJUST(ex))

so LD, when manipulating object files, just subtracts this mysterious 4k
off again (yuck)!

To continue with this BFD (gas-2.3+binutils-2.4:include/aout/aout64.h)
assumes that in the case of NMAGIC or OMAGIC it has an object file and
N_TXTADDR should be 0.

My question:

What purpose does this mysterious 4k serve?  Can someone please expand a
little on its history.  

						Andrew



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