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