a.out.gnu.h 5.0 KB

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