a.out.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. #ifndef __A_OUT_GNU_H__
  2. #define __A_OUT_GNU_H__
  3. #include <bits/a.out.h>
  4. #define __GNU_EXEC_MACROS__
  5. struct exec
  6. {
  7. unsigned long a_info; /* Use macros N_MAGIC, etc for access. */
  8. unsigned int a_text; /* Length of text, in bytes. */
  9. unsigned int a_data; /* Length of data, in bytes. */
  10. unsigned int a_bss; /* Length of uninitialized data area for file, in bytes. */
  11. unsigned int a_syms; /* Length of symbol table data in file, in bytes. */
  12. unsigned int a_entry; /* Start address. */
  13. unsigned int a_trsize;/* Length of relocation info for text, in bytes. */
  14. unsigned int a_drsize;/* Length of relocation info for data, in bytes. */
  15. };
  16. enum machine_type
  17. {
  18. M_OLDSUN2 = 0,
  19. M_68010 = 1,
  20. M_68020 = 2,
  21. M_SPARC = 3,
  22. M_386 = 100,
  23. M_MIPS1 = 151,
  24. M_MIPS2 = 152
  25. };
  26. #define N_MAGIC(exec) ((exec).a_info & 0xffff)
  27. #define N_MACHTYPE(exec) ((enum machine_type)(((exec).a_info >> 16) & 0xff))
  28. #define N_FLAGS(exec) (((exec).a_info >> 24) & 0xff)
  29. #define N_SET_INFO(exec, magic, type, flags) \
  30. ((exec).a_info = ((magic) & 0xffff) \
  31. | (((int)(type) & 0xff) << 16) \
  32. | (((flags) & 0xff) << 24))
  33. #define N_SET_MAGIC(exec, magic) \
  34. ((exec).a_info = ((exec).a_info & 0xffff0000) | ((magic) & 0xffff))
  35. #define N_SET_MACHTYPE(exec, machtype) \
  36. ((exec).a_info = \
  37. ((exec).a_info&0xff00ffff) | ((((int)(machtype))&0xff) << 16))
  38. #define N_SET_FLAGS(exec, flags) \
  39. ((exec).a_info = \
  40. ((exec).a_info&0x00ffffff) | (((flags) & 0xff) << 24))
  41. /* Code indicating object file or impure executable. */
  42. #define OMAGIC 0407
  43. /* Code indicating pure executable. */
  44. #define NMAGIC 0410
  45. /* Code indicating demand-paged executable. */
  46. #define ZMAGIC 0413
  47. /* This indicates a demand-paged executable with the header in the text.
  48. The first page is unmapped to help trap NULL pointer references. */
  49. #define QMAGIC 0314
  50. /* Code indicating core file. */
  51. #define CMAGIC 0421
  52. #define N_TRSIZE(a) ((a).a_trsize)
  53. #define N_DRSIZE(a) ((a).a_drsize)
  54. #define N_SYMSIZE(a) ((a).a_syms)
  55. #define N_BADMAG(x) \
  56. (N_MAGIC(x) != OMAGIC && N_MAGIC(x) != NMAGIC \
  57. && N_MAGIC(x) != ZMAGIC && N_MAGIC(x) != QMAGIC)
  58. #define _N_HDROFF(x) (1024 - sizeof (struct exec))
  59. #define N_TXTOFF(x) \
  60. (N_MAGIC(x) == ZMAGIC ? _N_HDROFF((x)) + sizeof (struct exec) : \
  61. (N_MAGIC(x) == QMAGIC ? 0 : sizeof (struct exec)))
  62. #define N_DATOFF(x) (N_TXTOFF(x) + (x).a_text)
  63. #define N_TRELOFF(x) (N_DATOFF(x) + (x).a_data)
  64. #define N_DRELOFF(x) (N_TRELOFF(x) + N_TRSIZE(x))
  65. #define N_SYMOFF(x) (N_DRELOFF(x) + N_DRSIZE(x))
  66. #define N_STROFF(x) (N_SYMOFF(x) + N_SYMSIZE(x))
  67. /* Address of text segment in memory after it is loaded. */
  68. #define N_TXTADDR(x) (N_MAGIC(x) == QMAGIC ? 4096 : 0)
  69. /* Address of data segment in memory after it is loaded. */
  70. #define SEGMENT_SIZE 1024
  71. #define _N_SEGMENT_ROUND(x) (((x) + SEGMENT_SIZE - 1) & ~(SEGMENT_SIZE - 1))
  72. #define _N_TXTENDADDR(x) (N_TXTADDR(x)+(x).a_text)
  73. #define N_DATADDR(x) \
  74. (N_MAGIC(x)==OMAGIC? (_N_TXTENDADDR(x)) \
  75. : (_N_SEGMENT_ROUND (_N_TXTENDADDR(x))))
  76. #define N_BSSADDR(x) (N_DATADDR(x) + (x).a_data)
  77. #if !defined (N_NLIST_DECLARED)
  78. struct nlist
  79. {
  80. union
  81. {
  82. char *n_name;
  83. struct nlist *n_next;
  84. long n_strx;
  85. } n_un;
  86. unsigned char n_type;
  87. char n_other;
  88. short n_desc;
  89. unsigned long n_value;
  90. };
  91. #endif /* no N_NLIST_DECLARED. */
  92. #define N_UNDF 0
  93. #define N_ABS 2
  94. #define N_TEXT 4
  95. #define N_DATA 6
  96. #define N_BSS 8
  97. #define N_FN 15
  98. #define N_EXT 1
  99. #define N_TYPE 036
  100. #define N_STAB 0340
  101. #define N_INDR 0xa
  102. #define N_SETA 0x14 /* Absolute set element symbol. */
  103. #define N_SETT 0x16 /* Text set element symbol. */
  104. #define N_SETD 0x18 /* Data set element symbol. */
  105. #define N_SETB 0x1A /* Bss set element symbol. */
  106. #define N_SETV 0x1C /* Pointer to set vector in data area. */
  107. #if !defined (N_RELOCATION_INFO_DECLARED)
  108. /* This structure describes a single relocation to be performed.
  109. The text-relocation section of the file is a vector of these structures,
  110. all of which apply to the text section.
  111. Likewise, the data-relocation section applies to the data section. */
  112. struct relocation_info
  113. {
  114. int r_address;
  115. unsigned int r_symbolnum:24;
  116. unsigned int r_pcrel:1;
  117. unsigned int r_length:2;
  118. unsigned int r_extern:1;
  119. unsigned int r_pad:4;
  120. };
  121. #endif /* no N_RELOCATION_INFO_DECLARED. */
  122. #endif /* __A_OUT_GNU_H__ */