home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Headers / mach-o / nlist.h < prev    next >
C/C++ Source or Header  |  1991-08-23  |  4KB  |  99 lines

  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_TYPE:4,
  40.  *              N_EXT:1;
  41.  * which are used via the following masks.
  42.  */
  43. #define    N_STAB    0xe0  /* if any of these bits set, a symbolic debugging entry */
  44. #define    N_TYPE    0x1e  /* mask for the type bits */
  45. #define    N_EXT    0x01  /* external symbol bit, set for external symbols */
  46.  
  47. /*
  48.  * Only symbolic debugging entries have some of the N_STAB bits set and if any
  49.  * of these bits are set then it is a symbolic debugging entry (a stab).  In
  50.  * which case then the values of the n_type field (the entire field) are given
  51.  * in <mach-o/stab.h>
  52.  */
  53.  
  54. /*
  55.  * Values for N_TYPE bits of the n_type field.
  56.  */
  57. #define    N_UNDF    0x0        /* undefined, n_sect == NO_SECT */
  58. #define    N_ABS    0x2        /* absolute, n_sect == NO_SECT */
  59. #define    N_SECT    0xe        /* defined in section number n_sect */
  60. #define N_INDR    0xa        /* indirect */
  61.  
  62. /* 
  63.  * If the type is N_INDR then the symbol is defined to be the same as another
  64.  * symbol.  In this case the n_value field is an index into the string table
  65.  * of the other symbol's name.  When the other symbol is defined then they both
  66.  * take on the defined type and value.
  67.  */
  68.  
  69. /*
  70.  * If the type is N_SECT then the n_sect field contains an ordinal of the
  71.  * section the symbol is defined in.  The sections are numbered from 1 and 
  72.  * refer to sections in order they appear in the load commands for the file
  73.  * they are in.  This means the same ordinal may very well refer to different
  74.  * sections in different files.
  75.  *
  76.  * The n_value field for all symbol table entries (including N_STAB's) gets
  77.  * updated by the link editor based on the value of it's n_sect field and where
  78.  * the section n_sect references gets relocated.  If the value of the n_sect 
  79.  * field is NO_SECT then it's n_value field is not changed by the link editor.
  80.  */
  81. #define    NO_SECT        0    /* symbol is not in any section */
  82. #define MAX_SECT    255    /* 1 thru 255 inclusive */
  83.  
  84. /*
  85.  * Common symbols are represented by undefined (N_UNDF) external (N_EXT) types
  86.  * who's values (n_value) are non-zero.  In which case the value of the n_value
  87.  * field is the size (in bytes) of the common symbol.  The n_sect field is set
  88.  * to NO_SECT.
  89.  */
  90.  
  91. #ifndef __STRICT_BSD__
  92. /*
  93.  * The function nlist(3) from the C library.
  94.  */
  95. extern int nlist (const char *filename, struct nlist *list);
  96. #endif __STRICT_BSD__
  97.  
  98. #endif _MACHO_LIST_H_
  99.