internal.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310
  1. /* NLM (NetWare Loadable Module) support for BFD.
  2. Copyright (C) 1993-2015 Free Software Foundation, Inc.
  3. Written by Fred Fish @ Cygnus Support.
  4. This file is part of BFD, the Binary File Descriptor library.
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 3 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
  16. MA 02110-1301, USA. */
  17. /* This file is part of NLM support for BFD, and contains the portions
  18. that describe how NLM is represented internally in the BFD library.
  19. I.E. it describes the in-memory representation of NLM. It requires
  20. the nlm/common.h file which contains the portions that are common to
  21. both the internal and external representations. */
  22. #if 0
  23. /* Types used by various structures, functions, etc. */
  24. typedef unsigned long Nlm32_Addr; /* Unsigned program address */
  25. typedef unsigned long Nlm32_Off; /* Unsigned file offset */
  26. typedef long Nlm32_Sword; /* Signed large integer */
  27. typedef unsigned long Nlm32_Word; /* Unsigned large integer */
  28. typedef unsigned short Nlm32_Half; /* Unsigned medium integer */
  29. typedef unsigned char Nlm32_Char; /* Unsigned tiny integer */
  30. #ifdef BFD_HOST_64_BIT
  31. typedef unsigned BFD_HOST_64_BIT Nlm64_Addr;
  32. typedef unsigned BFD_HOST_64_BIT Nlm64_Off;
  33. typedef BFD_HOST_64_BIT Nlm64_Sxword;
  34. typedef unsigned BFD_HOST_64_BIT Nlm64_Xword;
  35. #endif
  36. typedef long Nlm64_Sword;
  37. typedef unsigned long Nlm64_Word;
  38. typedef unsigned short Nlm64_Half;
  39. #endif /* 0 */
  40. /* This structure contains the internal form of the portion of the NLM
  41. header that is fixed length. */
  42. typedef struct nlm_internal_fixed_header
  43. {
  44. /* The signature field identifies the file as an NLM. It must contain
  45. the signature string, which depends upon the NLM target. */
  46. char signature[NLM_SIGNATURE_SIZE];
  47. /* The version of the header. At this time, the highest version number
  48. is 4. */
  49. long version;
  50. /* The name of the module, which must be a DOS name (1-8 characters followed
  51. by a period and a 1-3 character extension. The first byte is the byte
  52. length of the name and the last byte is a null terminator byte. This
  53. field is fixed length, and any unused bytes should be null bytes. The
  54. value is set by the OUTPUT keyword to NLMLINK. */
  55. char moduleName[NLM_MODULE_NAME_SIZE];
  56. /* The byte offset of the code image from the start of the file. */
  57. file_ptr codeImageOffset;
  58. /* The size of the code image, in bytes. */
  59. bfd_size_type codeImageSize;
  60. /* The byte offset of the data image from the start of the file. */
  61. file_ptr dataImageOffset;
  62. /* The size of the data image, in bytes. */
  63. bfd_size_type dataImageSize;
  64. /* The size of the uninitialized data region that the loader is to be
  65. allocated at load time. Uninitialized data follows the initialized
  66. data in the NLM address space. */
  67. bfd_size_type uninitializedDataSize;
  68. /* The byte offset of the custom data from the start of the file. The
  69. custom data is set by the CUSTOM keyword to NLMLINK. */
  70. file_ptr customDataOffset;
  71. /* The size of the custom data, in bytes. */
  72. bfd_size_type customDataSize;
  73. /* The byte offset of the module dependencies from the start of the file.
  74. The module dependencies are determined by the MODULE keyword in
  75. NLMLINK. */
  76. file_ptr moduleDependencyOffset;
  77. /* The number of module dependencies at the moduleDependencyOffset. */
  78. long numberOfModuleDependencies;
  79. /* The byte offset of the relocation fixup data from the start of the file */
  80. file_ptr relocationFixupOffset;
  81. long numberOfRelocationFixups;
  82. file_ptr externalReferencesOffset;
  83. long numberOfExternalReferences;
  84. file_ptr publicsOffset;
  85. long numberOfPublics;
  86. file_ptr debugInfoOffset;
  87. long numberOfDebugRecords;
  88. file_ptr codeStartOffset;
  89. file_ptr exitProcedureOffset;
  90. file_ptr checkUnloadProcedureOffset;
  91. long moduleType;
  92. long flags;
  93. } Nlm_Internal_Fixed_Header;
  94. #define nlm32_internal_fixed_header nlm_internal_fixed_header
  95. #define Nlm32_Internal_Fixed_Header Nlm_Internal_Fixed_Header
  96. #define nlm64_internal_fixed_header nlm_internal_fixed_header
  97. #define Nlm64_Internal_Fixed_Header Nlm_Internal_Fixed_Header
  98. /* This structure contains the portions of the NLM header that are either
  99. variable in size in the external representation, or else are not at a
  100. fixed offset relative to the start of the NLM header due to preceding
  101. variable sized fields.
  102. Note that all the fields must exist in the external header, and in
  103. the order used here (the same order is used in the internal form
  104. for consistency, not out of necessity). */
  105. typedef struct nlm_internal_variable_header
  106. {
  107. /* The descriptionLength field contains the length of the text in
  108. descriptionText, excluding the null terminator. The descriptionText
  109. field contains the NLM description obtained from the DESCRIPTION
  110. keyword in NLMLINK plus the null byte terminator. The descriptionText
  111. can be up to NLM_MAX_DESCRIPTION_LENGTH characters. */
  112. unsigned char descriptionLength;
  113. char descriptionText[NLM_MAX_DESCRIPTION_LENGTH + 1];
  114. /* The stackSize field contains the size of the stack in bytes, as
  115. specified by the STACK or STACKSIZE keyword in NLMLINK. If no size
  116. is specified, the default is NLM_DEFAULT_STACKSIZE. */
  117. long stackSize;
  118. /* The reserved field is included only for completeness. It should contain
  119. zero. */
  120. long reserved;
  121. /* This field is fixed length, should contain " LONG" (note leading
  122. space), and is unused. */
  123. char oldThreadName[NLM_OLD_THREAD_NAME_LENGTH];
  124. /* The screenNameLength field contains the length of the actual text stored
  125. in the screenName field, excluding the null byte terminator. The
  126. screenName field contains the screen name as specified by the SCREENNAME
  127. keyword in NLMLINK, and can be up to NLM_MAX_SCREEN_NAME_LENGTH
  128. characters. */
  129. unsigned char screenNameLength;
  130. char screenName[NLM_MAX_SCREEN_NAME_LENGTH + 1];
  131. /* The threadNameLength field contains the length of the actual text stored
  132. in the threadName field, excluding the null byte terminator. The
  133. threadName field contains the thread name as specified by the THREADNAME
  134. keyword in NLMLINK, and can be up to NLM_MAX_THREAD_NAME_LENGTH
  135. characters. */
  136. unsigned char threadNameLength;
  137. char threadName[NLM_MAX_THREAD_NAME_LENGTH + 1];
  138. } Nlm_Internal_Variable_Header;
  139. #define nlm32_internal_variable_header nlm_internal_variable_header
  140. #define Nlm32_Internal_Variable_Header Nlm_Internal_Variable_Header
  141. #define nlm64_internal_variable_header nlm_internal_variable_header
  142. #define Nlm64_Internal_Variable_Header Nlm_Internal_Variable_Header
  143. /* The version header is one of the optional auxiliary headers and
  144. follows the fixed length and variable length NLM headers. */
  145. typedef struct nlm_internal_version_header
  146. {
  147. /* The header is recognized by "VeRsIoN#" in the stamp field. */
  148. char stamp[8];
  149. long majorVersion;
  150. long minorVersion;
  151. long revision;
  152. long year;
  153. long month;
  154. long day;
  155. } Nlm_Internal_Version_Header;
  156. #define nlm32_internal_version_header nlm_internal_version_header
  157. #define Nlm32_Internal_Version_Header Nlm_Internal_Version_Header
  158. #define nlm64_internal_version_header nlm_internal_version_header
  159. #define Nlm64_Internal_Version_Header Nlm_Internal_Version_Header
  160. typedef struct nlm_internal_copyright_header
  161. {
  162. /* The header is recognized by "CoPyRiGhT=" in the stamp field. */
  163. char stamp[10];
  164. unsigned char copyrightMessageLength;
  165. char copyrightMessage[NLM_MAX_COPYRIGHT_MESSAGE_LENGTH];
  166. } Nlm_Internal_Copyright_Header;
  167. #define nlm32_internal_copyright_header nlm_internal_copyright_header
  168. #define Nlm32_Internal_Copyright_Header Nlm_Internal_Copyright_Header
  169. #define nlm64_internal_copyright_header nlm_internal_copyright_header
  170. #define Nlm64_Internal_Copyright_Header Nlm_Internal_Copyright_Header
  171. typedef struct nlm_internal_extended_header
  172. {
  173. /* The header is recognized by "MeSsAgEs" in the stamp field. */
  174. char stamp[8];
  175. long languageID;
  176. file_ptr messageFileOffset;
  177. bfd_size_type messageFileLength;
  178. long messageCount;
  179. file_ptr helpFileOffset;
  180. bfd_size_type helpFileLength;
  181. file_ptr RPCDataOffset;
  182. bfd_size_type RPCDataLength;
  183. file_ptr sharedCodeOffset;
  184. bfd_size_type sharedCodeLength;
  185. file_ptr sharedDataOffset;
  186. bfd_size_type sharedDataLength;
  187. file_ptr sharedRelocationFixupOffset;
  188. long sharedRelocationFixupCount;
  189. file_ptr sharedExternalReferenceOffset;
  190. long sharedExternalReferenceCount;
  191. file_ptr sharedPublicsOffset;
  192. long sharedPublicsCount;
  193. file_ptr sharedDebugRecordOffset;
  194. long sharedDebugRecordCount;
  195. bfd_vma SharedInitializationOffset;
  196. bfd_vma SharedExitProcedureOffset;
  197. long productID;
  198. long reserved0;
  199. long reserved1;
  200. long reserved2;
  201. long reserved3;
  202. long reserved4;
  203. long reserved5;
  204. } Nlm_Internal_Extended_Header;
  205. #define nlm32_internal_extended_header nlm_internal_extended_header
  206. #define Nlm32_Internal_Extended_Header Nlm_Internal_Extended_Header
  207. #define nlm64_internal_extended_header nlm_internal_extended_header
  208. #define Nlm64_Internal_Extended_Header Nlm_Internal_Extended_Header
  209. /* The format of a custom header as stored internally is different
  210. from the external format. This is how we store a custom header
  211. which we do not recognize. */
  212. typedef struct nlm_internal_custom_header
  213. {
  214. /* The header is recognized by "CuStHeAd" in the stamp field. */
  215. char stamp[8];
  216. bfd_size_type hdrLength;
  217. file_ptr dataOffset;
  218. bfd_size_type dataLength;
  219. char dataStamp[8];
  220. void *hdr;
  221. } Nlm_Internal_Custom_Header;
  222. #define nlm32_internal_custom_header nlm_internal_custom_header
  223. #define Nlm32_Internal_Custom_Header Nlm_Internal_Custom_Header
  224. #define nlm64_internal_custom_header nlm_internal_custom_header
  225. #define Nlm64_Internal_Custom_Header Nlm_Internal_Custom_Header
  226. /* The internal Cygnus header is written out externally as a custom
  227. header. We don't try to replicate that structure here. */
  228. typedef struct nlm_internal_cygnus_ext_header
  229. {
  230. /* The header is recognized by "CyGnUsEx" in the stamp field. */
  231. char stamp[8];
  232. /* File location of debugging information. */
  233. file_ptr offset;
  234. /* Length of debugging information. */
  235. bfd_size_type length;
  236. } Nlm_Internal_Cygnus_Ext_Header;
  237. #define nlm32_internal_cygnus_ext_header nlm_internal_cygnus_ext_header
  238. #define Nlm32_Internal_Cygnus_Ext_Header Nlm_Internal_Cygnus_Ext_Header
  239. #define nlm64_internal_cygnus_ext_header nlm_internal_cygnus_ext_header
  240. #define Nlm64_Internal_Cygnus_Ext_Header Nlm_Internal_Cygnus_Ext_Header