00001 /* NLM (NetWare Loadable Module) support for BFD. 00002 Copyright 1993, 1994, 2003 Free Software Foundation, Inc. 00003 00004 Written by Fred Fish @ Cygnus Support. 00005 00006 This file is part of BFD, the Binary File Descriptor library. 00007 00008 This program is free software; you can redistribute it and/or modify 00009 it under the terms of the GNU General Public License as published by 00010 the Free Software Foundation; either version 2 of the License, or 00011 (at your option) any later version. 00012 00013 This program is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with this program; if not, write to the Free Software 00020 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 00021 00022 00023 /* This file is part of NLM support for BFD, and contains the portions 00024 that describe how NLM is represented internally in the BFD library. 00025 I.E. it describes the in-memory representation of NLM. It requires 00026 the nlm/common.h file which contains the portions that are common to 00027 both the internal and external representations. */ 00028 00029 #if 0 00030 00031 /* Types used by various structures, functions, etc. */ 00032 00033 typedef unsigned long Nlm32_Addr; /* Unsigned program address */ 00034 typedef unsigned long Nlm32_Off; /* Unsigned file offset */ 00035 typedef long Nlm32_Sword; /* Signed large integer */ 00036 typedef unsigned long Nlm32_Word; /* Unsigned large integer */ 00037 typedef unsigned short Nlm32_Half; /* Unsigned medium integer */ 00038 typedef unsigned char Nlm32_Char; /* Unsigned tiny integer */ 00039 00040 #ifdef BFD_HOST_64_BIT 00041 typedef unsigned BFD_HOST_64_BIT Nlm64_Addr; 00042 typedef unsigned BFD_HOST_64_BIT Nlm64_Off; 00043 typedef BFD_HOST_64_BIT Nlm64_Sxword; 00044 typedef unsigned BFD_HOST_64_BIT Nlm64_Xword; 00045 #endif 00046 typedef long Nlm64_Sword; 00047 typedef unsigned long Nlm64_Word; 00048 typedef unsigned short Nlm64_Half; 00049 00050 #endif /* 0 */ 00051 00052 /* This structure contains the internal form of the portion of the NLM 00053 header that is fixed length. */ 00054 00055 typedef struct nlm_internal_fixed_header 00056 { 00057 /* The signature field identifies the file as an NLM. It must contain 00058 the signature string, which depends upon the NLM target. */ 00059 00060 char signature[NLM_SIGNATURE_SIZE]; 00061 00062 /* The version of the header. At this time, the highest version number 00063 is 4. */ 00064 00065 long version; 00066 00067 /* The name of the module, which must be a DOS name (1-8 characters followed 00068 by a period and a 1-3 character extension. The first byte is the byte 00069 length of the name and the last byte is a null terminator byte. This 00070 field is fixed length, and any unused bytes should be null bytes. The 00071 value is set by the OUTPUT keyword to NLMLINK. */ 00072 00073 char moduleName[NLM_MODULE_NAME_SIZE]; 00074 00075 /* The byte offset of the code image from the start of the file. */ 00076 00077 file_ptr codeImageOffset; 00078 00079 /* The size of the code image, in bytes. */ 00080 00081 bfd_size_type codeImageSize; 00082 00083 /* The byte offset of the data image from the start of the file. */ 00084 00085 file_ptr dataImageOffset; 00086 00087 /* The size of the data image, in bytes. */ 00088 00089 bfd_size_type dataImageSize; 00090 00091 /* The size of the uninitialized data region that the loader is to be 00092 allocated at load time. Uninitialized data follows the initialized 00093 data in the NLM address space. */ 00094 00095 bfd_size_type uninitializedDataSize; 00096 00097 /* The byte offset of the custom data from the start of the file. The 00098 custom data is set by the CUSTOM keyword to NLMLINK. */ 00099 00100 file_ptr customDataOffset; 00101 00102 /* The size of the custom data, in bytes. */ 00103 00104 bfd_size_type customDataSize; 00105 00106 /* The byte offset of the module dependencies from the start of the file. 00107 The module dependencies are determined by the MODULE keyword in 00108 NLMLINK. */ 00109 00110 file_ptr moduleDependencyOffset; 00111 00112 /* The number of module dependencies at the moduleDependencyOffset. */ 00113 00114 long numberOfModuleDependencies; 00115 00116 /* The byte offset of the relocation fixup data from the start of the file */ 00117 00118 file_ptr relocationFixupOffset; 00119 long numberOfRelocationFixups; 00120 file_ptr externalReferencesOffset; 00121 long numberOfExternalReferences; 00122 file_ptr publicsOffset; 00123 long numberOfPublics; 00124 file_ptr debugInfoOffset; 00125 long numberOfDebugRecords; 00126 file_ptr codeStartOffset; 00127 file_ptr exitProcedureOffset; 00128 file_ptr checkUnloadProcedureOffset; 00129 long moduleType; 00130 long flags; 00131 } Nlm_Internal_Fixed_Header; 00132 00133 #define nlm32_internal_fixed_header nlm_internal_fixed_header 00134 #define Nlm32_Internal_Fixed_Header Nlm_Internal_Fixed_Header 00135 #define nlm64_internal_fixed_header nlm_internal_fixed_header 00136 #define Nlm64_Internal_Fixed_Header Nlm_Internal_Fixed_Header 00137 00138 /* This structure contains the portions of the NLM header that are either 00139 variable in size in the external representation, or else are not at a 00140 fixed offset relative to the start of the NLM header due to preceding 00141 variable sized fields. 00142 00143 Note that all the fields must exist in the external header, and in 00144 the order used here (the same order is used in the internal form 00145 for consistency, not out of necessity). */ 00146 00147 typedef struct nlm_internal_variable_header 00148 { 00149 00150 /* The descriptionLength field contains the length of the text in 00151 descriptionText, excluding the null terminator. The descriptionText 00152 field contains the NLM description obtained from the DESCRIPTION 00153 keyword in NLMLINK plus the null byte terminator. The descriptionText 00154 can be up to NLM_MAX_DESCRIPTION_LENGTH characters. */ 00155 00156 unsigned char descriptionLength; 00157 char descriptionText[NLM_MAX_DESCRIPTION_LENGTH + 1]; 00158 00159 /* The stackSize field contains the size of the stack in bytes, as 00160 specified by the STACK or STACKSIZE keyword in NLMLINK. If no size 00161 is specified, the default is NLM_DEFAULT_STACKSIZE. */ 00162 00163 long stackSize; 00164 00165 /* The reserved field is included only for completeness. It should contain 00166 zero. */ 00167 00168 long reserved; 00169 00170 /* This field is fixed length, should contain " LONG" (note leading 00171 space), and is unused. */ 00172 00173 char oldThreadName[NLM_OLD_THREAD_NAME_LENGTH]; 00174 00175 /* The screenNameLength field contains the length of the actual text stored 00176 in the screenName field, excluding the null byte terminator. The 00177 screenName field contains the screen name as specified by the SCREENNAME 00178 keyword in NLMLINK, and can be up to NLM_MAX_SCREEN_NAME_LENGTH 00179 characters. */ 00180 00181 unsigned char screenNameLength; 00182 char screenName[NLM_MAX_SCREEN_NAME_LENGTH + 1]; 00183 00184 /* The threadNameLength field contains the length of the actual text stored 00185 in the threadName field, excluding the null byte terminator. The 00186 threadName field contains the thread name as specified by the THREADNAME 00187 keyword in NLMLINK, and can be up to NLM_MAX_THREAD_NAME_LENGTH 00188 characters. */ 00189 00190 unsigned char threadNameLength; 00191 char threadName[NLM_MAX_THREAD_NAME_LENGTH + 1]; 00192 00193 } Nlm_Internal_Variable_Header; 00194 00195 #define nlm32_internal_variable_header nlm_internal_variable_header 00196 #define Nlm32_Internal_Variable_Header Nlm_Internal_Variable_Header 00197 #define nlm64_internal_variable_header nlm_internal_variable_header 00198 #define Nlm64_Internal_Variable_Header Nlm_Internal_Variable_Header 00199 00200 /* The version header is one of the optional auxiliary headers and 00201 follows the fixed length and variable length NLM headers. */ 00202 00203 typedef struct nlm_internal_version_header 00204 { 00205 /* The header is recognized by "VeRsIoN#" in the stamp field. */ 00206 char stamp[8]; 00207 long majorVersion; 00208 long minorVersion; 00209 long revision; 00210 long year; 00211 long month; 00212 long day; 00213 } Nlm_Internal_Version_Header; 00214 00215 #define nlm32_internal_version_header nlm_internal_version_header 00216 #define Nlm32_Internal_Version_Header Nlm_Internal_Version_Header 00217 #define nlm64_internal_version_header nlm_internal_version_header 00218 #define Nlm64_Internal_Version_Header Nlm_Internal_Version_Header 00219 00220 typedef struct nlm_internal_copyright_header 00221 { 00222 /* The header is recognized by "CoPyRiGhT=" in the stamp field. */ 00223 char stamp[10]; 00224 unsigned char copyrightMessageLength; 00225 char copyrightMessage[NLM_MAX_COPYRIGHT_MESSAGE_LENGTH]; 00226 } Nlm_Internal_Copyright_Header; 00227 00228 #define nlm32_internal_copyright_header nlm_internal_copyright_header 00229 #define Nlm32_Internal_Copyright_Header Nlm_Internal_Copyright_Header 00230 #define nlm64_internal_copyright_header nlm_internal_copyright_header 00231 #define Nlm64_Internal_Copyright_Header Nlm_Internal_Copyright_Header 00232 00233 typedef struct nlm_internal_extended_header 00234 { 00235 /* The header is recognized by "MeSsAgEs" in the stamp field. */ 00236 char stamp[8]; 00237 long languageID; 00238 file_ptr messageFileOffset; 00239 bfd_size_type messageFileLength; 00240 long messageCount; 00241 file_ptr helpFileOffset; 00242 bfd_size_type helpFileLength; 00243 file_ptr RPCDataOffset; 00244 bfd_size_type RPCDataLength; 00245 file_ptr sharedCodeOffset; 00246 bfd_size_type sharedCodeLength; 00247 file_ptr sharedDataOffset; 00248 bfd_size_type sharedDataLength; 00249 file_ptr sharedRelocationFixupOffset; 00250 long sharedRelocationFixupCount; 00251 file_ptr sharedExternalReferenceOffset; 00252 long sharedExternalReferenceCount; 00253 file_ptr sharedPublicsOffset; 00254 long sharedPublicsCount; 00255 file_ptr sharedDebugRecordOffset; 00256 long sharedDebugRecordCount; 00257 bfd_vma SharedInitializationOffset; 00258 bfd_vma SharedExitProcedureOffset; 00259 long productID; 00260 long reserved0; 00261 long reserved1; 00262 long reserved2; 00263 long reserved3; 00264 long reserved4; 00265 long reserved5; 00266 } Nlm_Internal_Extended_Header; 00267 00268 #define nlm32_internal_extended_header nlm_internal_extended_header 00269 #define Nlm32_Internal_Extended_Header Nlm_Internal_Extended_Header 00270 #define nlm64_internal_extended_header nlm_internal_extended_header 00271 #define Nlm64_Internal_Extended_Header Nlm_Internal_Extended_Header 00272 00273 /* The format of a custom header as stored internally is different 00274 from the external format. This is how we store a custom header 00275 which we do not recognize. */ 00276 00277 typedef struct nlm_internal_custom_header 00278 { 00279 /* The header is recognized by "CuStHeAd" in the stamp field. */ 00280 char stamp[8]; 00281 bfd_size_type hdrLength; 00282 file_ptr dataOffset; 00283 bfd_size_type dataLength; 00284 char dataStamp[8]; 00285 void *hdr; 00286 } Nlm_Internal_Custom_Header; 00287 00288 #define nlm32_internal_custom_header nlm_internal_custom_header 00289 #define Nlm32_Internal_Custom_Header Nlm_Internal_Custom_Header 00290 #define nlm64_internal_custom_header nlm_internal_custom_header 00291 #define Nlm64_Internal_Custom_Header Nlm_Internal_Custom_Header 00292 00293 /* The internal Cygnus header is written out externally as a custom 00294 header. We don't try to replicate that structure here. */ 00295 00296 typedef struct nlm_internal_cygnus_ext_header 00297 { 00298 /* The header is recognized by "CyGnUsEx" in the stamp field. */ 00299 char stamp[8]; 00300 /* File location of debugging information. */ 00301 file_ptr offset; 00302 /* Length of debugging information. */ 00303 bfd_size_type length; 00304 } Nlm_Internal_Cygnus_Ext_Header; 00305 00306 #define nlm32_internal_cygnus_ext_header nlm_internal_cygnus_ext_header 00307 #define Nlm32_Internal_Cygnus_Ext_Header Nlm_Internal_Cygnus_Ext_Header 00308 #define nlm64_internal_cygnus_ext_header nlm_internal_cygnus_ext_header 00309 #define Nlm64_Internal_Cygnus_Ext_Header Nlm_Internal_Cygnus_Ext_Header
1.5.6