Annotation of GNUtools/cctools/include/mach-o/nlist.h, revision 1.1.1.1

1.1       root        1: #ifndef _MACHO_NLIST_H_
                      2: #define _MACHO_NLIST_H_
                      3: /*
                      4:  * Copyright (c) 1980 Regents of the University of California.
                      5:  * All rights reserved.  The Berkeley software License Agreement
                      6:  * specifies the terms and conditions for redistribution.
                      7:  *
                      8:  *     @(#)nlist.h     5.1 (Berkeley) 5/30/85
                      9:  */
                     10: 
                     11: /*
                     12:  * Format of a symbol table entry of a Mach-O file.  Modified from the 4.3BSD
                     13:  * format.  The modifications from the original format were changing n_other
                     14:  * (an unused field) to n_sect and the addition of the N_SECT type.  These
                     15:  * modifications are required to support symbols in an arbitrary number of
                     16:  * sections not just the three sections (text, data and bss) in a 4.3BSD file.
                     17:  */
                     18: struct nlist {
                     19:        union {
                     20:                char *n_name;   /* for use when in-core */
                     21:                long  n_strx;   /* index into the string table */
                     22:        } n_un;
                     23:        unsigned char n_type;   /* type flag, see below */
                     24:        unsigned char n_sect;   /* section number or NO_SECT */
                     25:        short         n_desc;   /* see <mach-o/stab.h> */
                     26:        unsigned long n_value;  /* value of this symbol (or stab offset) */
                     27: };
                     28: 
                     29: /*
                     30:  * Symbols with a index into the string table of zero (n_un.n_strx == 0) are
                     31:  * defined to have a null, "", name.  Therefore all string indexes to non null
                     32:  * names must not have a zero string index.  This is bit historical information
                     33:  * that has never been well documented.
                     34:  */
                     35: 
                     36: /*
                     37:  * The n_type field really contains three fields:
                     38:  *     unsigned char N_STAB:3,
                     39:  *                   N_PEXT:1,
                     40:  *                   N_TYPE:3,
                     41:  *                   N_EXT:1;
                     42:  * which are used via the following masks.
                     43:  */
                     44: #define        N_STAB  0xe0  /* if any of these bits set, a symbolic debugging entry */
                     45: #define        N_PEXT  0x10  /* private external symbol bit */
                     46: #define        N_TYPE  0x0e  /* mask for the type bits */
                     47: #define        N_EXT   0x01  /* external symbol bit, set for external symbols */
                     48: 
                     49: /*
                     50:  * Only symbolic debugging entries have some of the N_STAB bits set and if any
                     51:  * of these bits are set then it is a symbolic debugging entry (a stab).  In
                     52:  * which case then the values of the n_type field (the entire field) are given
                     53:  * in <mach-o/stab.h>
                     54:  */
                     55: 
                     56: /*
                     57:  * Values for N_TYPE bits of the n_type field.
                     58:  */
                     59: #define        N_UNDF  0x0             /* undefined, n_sect == NO_SECT */
                     60: #define        N_ABS   0x2             /* absolute, n_sect == NO_SECT */
                     61: #define        N_SECT  0xe             /* defined in section number n_sect */
                     62: #define N_INDR 0xa             /* indirect */
                     63: 
                     64: /* 
                     65:  * If the type is N_INDR then the symbol is defined to be the same as another
                     66:  * symbol.  In this case the n_value field is an index into the string table
                     67:  * of the other symbol's name.  When the other symbol is defined then they both
                     68:  * take on the defined type and value.
                     69:  */
                     70: 
                     71: /*
                     72:  * If the type is N_SECT then the n_sect field contains an ordinal of the
                     73:  * section the symbol is defined in.  The sections are numbered from 1 and 
                     74:  * refer to sections in order they appear in the load commands for the file
                     75:  * they are in.  This means the same ordinal may very well refer to different
                     76:  * sections in different files.
                     77:  *
                     78:  * The n_value field for all symbol table entries (including N_STAB's) gets
                     79:  * updated by the link editor based on the value of it's n_sect field and where
                     80:  * the section n_sect references gets relocated.  If the value of the n_sect 
                     81:  * field is NO_SECT then it's n_value field is not changed by the link editor.
                     82:  */
                     83: #define        NO_SECT         0       /* symbol is not in any section */
                     84: #define MAX_SECT       255     /* 1 thru 255 inclusive */
                     85: 
                     86: /*
                     87:  * Common symbols are represented by undefined (N_UNDF) external (N_EXT) types
                     88:  * who's values (n_value) are non-zero.  In which case the value of the n_value
                     89:  * field is the size (in bytes) of the common symbol.  The n_sect field is set
                     90:  * to NO_SECT.
                     91:  */
                     92: 
                     93: /*
                     94:  * To support the lazy binding of undefined symbols in the dynamic link-editor,
                     95:  * the undefined symbols in the symbol table (the nlist structures) are marked
                     96:  * with the indication if the undefined reference is a lazy reference or
                     97:  * non-lazy reference.  If both a non-lazy reference and a lazy reference is
                     98:  * made to the same symbol the non-lazy reference takes precedence.  A reference
                     99:  * is lazy only when all references to that symbol are made through a symbol
                    100:  * pointer in a lazy symbol pointer section.
                    101:  *
                    102:  * The implementation of marking nlist structures in the symbol table for
                    103:  * undefined symbols will be to use some of the bits of the n_desc field as a
                    104:  * reference type.  The mask REFERENCE_TYPE will be applied to the n_desc field
                    105:  * of an nlist structure for an undefined symbol to determine the type of
                    106:  * undefined reference (lazy or non-lazy).
                    107:  *
                    108:  * The constants for the REFERENCE FLAGS are propagated to the reference table
                    109:  * in a shared library file.  In that case the constant for a defined symbol,
                    110:  * REFERENCE_FLAG_DEFINED, is also used.
                    111:  */
                    112: /* Reference type bits of the n_desc field of undefined symbols */
                    113: #define REFERENCE_TYPE                         0xff
                    114: /* types of references */
                    115: #define REFERENCE_FLAG_UNDEFINED_NON_LAZY              0
                    116: #define REFERENCE_FLAG_UNDEFINED_LAZY                  1
                    117: #define REFERENCE_FLAG_DEFINED                         2
                    118: #define REFERENCE_FLAG_PRIVATE_DEFINED                 3
                    119: #define REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY      4
                    120: #define REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY          5
                    121: 
                    122: #ifndef __STRICT_BSD__
                    123: /*
                    124:  * The function nlist(3) from the C library.
                    125:  */
                    126: extern int nlist (const char *filename, struct nlist *list);
                    127: #endif __STRICT_BSD__
                    128: 
                    129: #endif _MACHO_LIST_H_

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.