a.out.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /* Copyright (C) 1990-1996
  2. * This file is part of the ld86 command for Linux-86
  3. * It is distributed under the GNU Library General Public License.
  4. *
  5. * - This may actually be BSD or Minix code, can someone clarify please. -RDB
  6. */
  7. #ifndef __AOUT_H
  8. #define __AOUT_H
  9. struct exec { /* a.out header */
  10. unsigned char a_magic[2]; /* magic number */
  11. unsigned char a_flags; /* flags, see below */
  12. unsigned char a_cpu; /* cpu id */
  13. unsigned char a_hdrlen; /* length of header */
  14. unsigned char a_unused; /* reserved for future use */
  15. unsigned short a_version; /* version stamp (not used at present) */
  16. long a_text; /* size of text segement in bytes */
  17. long a_data; /* size of data segment in bytes */
  18. long a_bss; /* size of bss segment in bytes */
  19. long a_entry; /* entry point */
  20. long a_total; /* total memory allocated */
  21. long a_syms; /* size of symbol table */
  22. /* SHORT FORM ENDS HERE */
  23. long a_trsize; /* text relocation size */
  24. long a_drsize; /* data relocation size */
  25. long a_tbase; /* text relocation base */
  26. long a_dbase; /* data relocation base */
  27. };
  28. #define A_MAGIC0 (unsigned char) 0x01
  29. #define A_MAGIC1 (unsigned char) 0x03
  30. #define BADMAG(X) ((X).a_magic[0] != A_MAGIC0 ||(X).a_magic[1] != A_MAGIC1)
  31. /* CPU Id of TARGET machine (byte order coded in low order two bits) */
  32. #define A_NONE 0x00 /* unknown */
  33. #define A_I8086 0x04 /* intel i8086/8088 */
  34. #define A_M68K 0x0B /* motorola m68000 */
  35. #define A_NS16K 0x0C /* national semiconductor 16032 */
  36. #define A_I80386 0x10 /* intel i80386 */
  37. #define A_SPARC 0x17 /* Sun SPARC */
  38. #define A_BLR(cputype) ((cputype&0x01)!=0) /* TRUE if bytes left-to-right */
  39. #define A_WLR(cputype) ((cputype&0x02)!=0) /* TRUE if words left-to-right */
  40. /* Flags. */
  41. #define A_UZP 0x01 /* unmapped zero page (pages) */
  42. #define A_PAL 0x02 /* page aligned executable */
  43. #define A_NSYM 0x04 /* new style symbol table */
  44. #define A_EXEC 0x10 /* executable */
  45. #define A_SEP 0x20 /* separate I/D */
  46. #define A_PURE 0x40 /* pure text */
  47. #define A_TOVLY 0x80 /* text overlay */
  48. /* Offsets of various things. */
  49. #define A_MINHDR 32
  50. #define A_TEXTPOS(X) ((long)(X).a_hdrlen)
  51. #define A_DATAPOS(X) (A_TEXTPOS(X) + (X).a_text)
  52. #define A_HASRELS(X) ((X).a_hdrlen > (unsigned char) A_MINHDR)
  53. #define A_HASEXT(X) ((X).a_hdrlen > (unsigned char) (A_MINHDR + 8))
  54. #define A_HASLNS(X) ((X).a_hdrlen > (unsigned char) (A_MINHDR + 16))
  55. #define A_HASTOFF(X) ((X).a_hdrlen > (unsigned char) (A_MINHDR + 24))
  56. #define A_TRELPOS(X) (A_DATAPOS(X) + (X).a_data)
  57. #define A_DRELPOS(X) (A_TRELPOS(X) + (X).a_trsize)
  58. #define A_SYMPOS(X) (A_TRELPOS(X) + (A_HASRELS(X) ? \
  59. ((X).a_trsize + (X).a_drsize) : 0))
  60. struct reloc {
  61. long r_vaddr; /* virtual address of reference */
  62. unsigned short r_symndx; /* internal segnum or extern symbol num */
  63. unsigned short r_type; /* relocation type */
  64. };
  65. /* r_tyep values: */
  66. #define R_ABBS 0
  67. #define R_RELLBYTE 2
  68. #define R_PCRBYTE 3
  69. #define R_RELWORD 4
  70. #define R_PCRWORD 5
  71. #define R_RELLONG 6
  72. #define R_PCRLONG 7
  73. #define R_REL3BYTE 8
  74. #define R_KBRANCHE 9
  75. /* r_symndx for internal segments */
  76. #define S_ABS ((unsigned short)-1)
  77. #define S_TEXT ((unsigned short)-2)
  78. #define S_DATA ((unsigned short)-3)
  79. #define S_BSS ((unsigned short)-4)
  80. struct nlist { /* symbol table entry */
  81. char n_name[8]; /* symbol name */
  82. long n_value; /* value */
  83. unsigned char n_sclass; /* storage class */
  84. unsigned char n_numaux; /* number of auxiliary entries (not used) */
  85. unsigned short n_type; /* language base and derived type (not used) */
  86. };
  87. /* Low bits of storage class (section). */
  88. #define N_SECT 07 /* section mask */
  89. #define N_UNDF 00 /* undefined */
  90. #define N_ABS 01 /* absolute */
  91. #define N_TEXT 02 /* text */
  92. #define N_DATA 03 /* data */
  93. #define N_BSS 04 /* bss */
  94. #define N_COMM 05 /* (common) */
  95. /* High bits of storage class. */
  96. #define N_CLASS 0370 /* storage class mask */
  97. #define C_NULL
  98. #define C_EXT 0020 /* external symbol */
  99. #define C_STAT 0030 /* static */
  100. #endif /* _AOUT_H */