home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / zip / gnu / utlsrc33.lzh / UTLSRC33 / GNU-OUT_.OLD < prev    next >
Text File  |  1993-07-30  |  5KB  |  171 lines

  1.  
  2. struct exec
  3. {
  4. #ifdef COFF_ENCAPSULATE
  5.   unsigned short a_magic;
  6.   unsigned char a_machtype;
  7.   unsigned char a_flags;
  8. #else
  9.   long a_magic;            /* number identifies as .o file and gives type of such. */
  10. #endif
  11.   unsigned a_text;        /* length of text, in bytes */
  12.   unsigned a_data;        /* length of data, in bytes */
  13.   unsigned a_bss;        /* length of uninitialized data area for file, in bytes */
  14.   unsigned a_syms;        /* length of symbol table data in file, in bytes */
  15.   unsigned a_entry;        /* start address */
  16.   unsigned a_trsize;        /* length of relocation info for text, in bytes */
  17.   unsigned a_drsize;        /* length of relocation info for data, in bytes */
  18. };
  19.  
  20. /* these go in the a_machtype field */
  21. #define M_68010 1 /* sun defined these */
  22. #define M_68020 2
  23.  
  24. #define M_386 100 /* skip a bunch so we don't conflict with sun's numbers */
  25.  
  26. /* Code indicating object file or impure executable.  */
  27. #define OMAGIC 0407
  28. /* Code indicating pure executable.  */
  29. #define NMAGIC 0410
  30. /* Code indicating demand-paged executable.  */
  31. #define ZMAGIC 0413
  32.  
  33. #define N_BADMAG(x)                    \
  34.  (((x).a_magic) != OMAGIC && ((x).a_magic) != NMAGIC    \
  35.   && ((x).a_magic) != ZMAGIC)
  36.  
  37. #define _N_HDROFF(x) (1024 - sizeof (struct exec))
  38.  
  39. #define N_TXTOFF(x) \
  40.  ((x).a_magic == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : sizeof (struct exec))
  41.  
  42. #define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
  43.  
  44. #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
  45.  
  46. #define N_DRELOFF(x) (N_TRELOFF(x) + (x).a_trsize)
  47.  
  48. #define N_SYMOFF(x) (N_DRELOFF(x) + (x).a_drsize)
  49.  
  50. #define N_STROFF(x) (N_SYMOFF(x) + (x).a_syms)
  51.  
  52. /* Address of text segment in memory after it is loaded.  */
  53. #define N_TXTADDR(x) 0
  54.  
  55. /* Address of data segment in memory after it is loaded.
  56.    Note that it is up to you to define SEGMENT_SIZE
  57.    on machines not listed here.  */
  58. #ifdef CROSSATARI
  59. #  ifdef vax
  60. #    undef vax
  61. #  endif
  62. #  ifdef is68k
  63. #    undef is68k
  64. #  endif
  65. #endif
  66.  
  67. #ifdef vax
  68. #define SEGMENT_SIZE page_size
  69. #endif
  70. #ifdef is68k
  71. #define SEGMENT_SIZE 0x20000
  72. #endif
  73. #if (!(defined(is68k) || defined(vax)))
  74. #define SEGMENT_SIZE 2        /* random memory, halfword boundary */
  75. #endif
  76.  
  77. #ifndef N_DATADDR
  78. #define N_DATADDR(x) \
  79.     (((x).a_magic==OMAGIC)? (N_TXTADDR(x)+(x).a_text) \
  80.      : (SEGMENT_SIZE + ((N_TXTADDR(x)+(x).a_text-1) & ~(SEGMENT_SIZE-1))))
  81. #endif
  82.  
  83. /* Address of bss segment in memory after it is loaded.  */
  84. #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
  85.  
  86. struct nlist {
  87.   union {
  88.     char *n_name;
  89.     struct nlist *n_next;
  90.     long n_strx;
  91.   } n_un;
  92.   unsigned char  n_type;
  93.   unsigned char  n_other;
  94.   unsigned short n_desc;
  95.   unsigned long  n_value;
  96. };
  97.  
  98. #define N_UNDF 0
  99. #define N_ABS 2
  100. #define N_TEXT 4
  101. #define N_DATA 6
  102. #define N_BSS 8
  103. /* #define N_FN 15 */
  104. #define N_FN    31        /* JF: Someone claims this should be 31 instead of
  105.                15.  I just inherited this file; I didn't write
  106.                it.  Who is right? */
  107.  
  108. #define N_EXT 1
  109. #define N_TYPE 036
  110. #define N_STAB 0340
  111.  
  112. /* The following type indicates the definition of a symbol as being
  113.    an indirect reference to another symbol.  The other symbol
  114.    appears as an undefined reference, immediately following this symbol.
  115.  
  116.    Indirection is asymmetrical.  The other symbol's value will be used
  117.    to satisfy requests for the indirect symbol, but not vice versa.
  118.    If the other symbol does not have a definition, libraries will
  119.    be searched to find a definition.  */
  120. #define N_INDR 0xa
  121.  
  122. /* The following symbols refer to set elements.
  123.    All the N_SET[ATDB] symbols with the same name form one set.
  124.    Space is allocated for the set in the text section, and each set
  125.    element's value is stored into one word of the space.
  126.    The first word of the space is the length of the set (number of elements).
  127.  
  128.    The address of the set is made into an N_SETV symbol
  129.    whose name is the same as the name of the set.
  130.    This symbol acts like a N_TEXT global symbol
  131.    in that it can satisfy undefined external references.  */
  132.  
  133. /* These appear as input to LD, in a .o file.  */
  134. #define    N_SETA    0x14        /* Absolute set element symbol */
  135. #define    N_SETT    0x16        /* Text set element symbol */
  136. #define    N_SETD    0x18        /* Data set element symbol */
  137. #define    N_SETB    0x1A        /* Bss set element symbol */
  138.  
  139. /* This is output from LD.  */
  140. #define N_SETV    0x1C        /* Pointer to set vector in text area.  */
  141.  
  142. /* This structure describes a single relocation to be performed.
  143.    The text-relocation section of the file is a vector of these structures,
  144.    all of which apply to the text section.
  145.    Likewise, the data-relocation section applies to the data section.  */
  146.  
  147. struct relocation_info
  148. {
  149.   /* Address (within segment) to be relocated.  */
  150.   int r_address;
  151.   /* The meaning of r_symbolnum depends on r_extern.  */
  152.   unsigned int r_symbolnum:24;
  153.   /* Nonzero means value is a pc-relative offset
  154.      and it should be relocated for changes in its own address
  155.      as well as for changes in the symbol or section specified.  */
  156.   unsigned int r_pcrel:1;
  157.   /* Length (as exponent of 2) of the field to be relocated.
  158.      Thus, a value of 2 indicates 1<<2 bytes.  */
  159.   unsigned int r_length:2;
  160.   /* 1 => relocate with value of symbol.
  161.           r_symbolnum is the index of the symbol
  162.       in file's the symbol table.
  163.      0 => relocate with the address of a segment.
  164.           r_symbolnum is N_TEXT, N_DATA, N_BSS or N_ABS
  165.       (the N_EXT bit may be set also, but signifies nothing).  */
  166.   unsigned int r_extern:1;
  167.   /* Four bits that aren't used, but when writing an object file
  168.      it is desirable to clear them.  */
  169.   unsigned int r_pad:4;
  170. };
  171.