From 8ae5cb6ecbdc57c3ad7e21dd935d35b5d5adf390 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Wed, 27 Oct 1993 15:46:57 +0000 Subject: [PATCH] * common.h (NLM_SIGNATURE): Do not define (it's different for each backend). Also minor comment changes to internal.h and external.h. --- include/nlm/ChangeLog | 24 ++++ include/nlm/external.h | 147 +++++++++++---------- include/nlm/internal.h | 283 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 379 insertions(+), 75 deletions(-) create mode 100644 include/nlm/internal.h diff --git a/include/nlm/ChangeLog b/include/nlm/ChangeLog index cd674d4ab72..74a84c15e97 100644 --- a/include/nlm/ChangeLog +++ b/include/nlm/ChangeLog @@ -1,3 +1,27 @@ +Wed Oct 27 11:45:56 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * common.h (NLM_SIGNATURE): Do not define (it's different for each + backend). + +Tue Aug 31 13:24:15 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * internal.h: Change length fields of type char to type unsigned + char. + +Sat Jul 31 02:12:14 1993 Ian Lance Taylor (ian@tweedledumb.cygnus.com) + + * common.h (NLM_HIBIT, NLM_HEADER_VERSION): Define. + +Thu Jul 22 16:09:47 1993 Fred Fish (fnf@deneb.cygnus.com) + + * common.h (NLM_CAT*, NLM_ARCH_SIZE, NLM_TARGET_LONG_SIZE, + NLM_TARGET_ADDRESS_SIZE, NLM_NAME, NlmNAME, nlmNAME): New + macros. + * external.h (TARGET_LONG_SIZE, TARGET_ADDRESS_SIZE): Remove + macros, convert usages to NLM_ equivalents. + * external.h: Use nlmNAME and NlmNAME macros to derive both + 32 and 64 bit versions. + Mon Jul 19 22:12:40 1993 Fred Fish (fnf@deneb.cygnus.com) * (common.h, external.h, internal.h): New files for NLM/NetWare diff --git a/include/nlm/external.h b/include/nlm/external.h index 6e565e4bb57..83592d06066 100644 --- a/include/nlm/external.h +++ b/include/nlm/external.h @@ -37,25 +37,23 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ (3) A auxiliary header that has various optional fields in no specific order. There is no way to identify the end of the auxiliary headers except by finding a header without a recognized 'stamp'. + */ -#define TARGET_LONG_SIZE 4 -#define TARGET_ADDRESS_SIZE 4 - -/* NLM Header (32-bit implementations) */ +/* NLM Header */ -typedef struct nlm32_external_fixed_header +typedef struct nlmNAME(external_fixed_header) { /* The signature field identifies the file as an NLM. It must contain - the string defined by NLM_SIGNATURE. */ + the signature string, which depends upon the NLM target. */ unsigned char signature[NLM_SIGNATURE_SIZE]; /* The version of the header. At this time, the highest version number is 4. */ - unsigned char version[TARGET_LONG_SIZE]; + unsigned char version[NLM_TARGET_LONG_SIZE]; /* The name of the module, which must be a DOS name (1-8 characters followed by a period and a 1-3 character extension). The first byte is the byte @@ -67,104 +65,104 @@ typedef struct nlm32_external_fixed_header /* The byte offset of the code image from the start of the file. */ - unsigned char codeImageOffset[TARGET_LONG_SIZE]; + unsigned char codeImageOffset[NLM_TARGET_LONG_SIZE]; /* The size of the code image, in bytes. */ - unsigned char codeImageSize[TARGET_LONG_SIZE]; + unsigned char codeImageSize[NLM_TARGET_LONG_SIZE]; /* The byte offset of the data image from the start of the file. */ - unsigned char dataImageOffset[TARGET_LONG_SIZE]; + unsigned char dataImageOffset[NLM_TARGET_LONG_SIZE]; /* The size of the data image, in bytes. */ - unsigned char dataImageSize[TARGET_LONG_SIZE]; + unsigned char dataImageSize[NLM_TARGET_LONG_SIZE]; /* The size of the uninitialized data region that the loader is to be allocated at load time. Uninitialized data follows the initialized data in the NLM address space. */ - unsigned char uninitializedDataSize[TARGET_LONG_SIZE]; + unsigned char uninitializedDataSize[NLM_TARGET_LONG_SIZE]; /* The byte offset of the custom data from the start of the file. The custom data is set by the CUSTOM keyword to NLMLINK. It is possible for this to be EOF if there is no custom data. */ - unsigned char customDataOffset[TARGET_LONG_SIZE]; + unsigned char customDataOffset[NLM_TARGET_LONG_SIZE]; /* The size of the custom data, in bytes. */ - unsigned char customDataSize[TARGET_LONG_SIZE]; + unsigned char customDataSize[NLM_TARGET_LONG_SIZE]; /* The byte offset of the module dependencies from the start of the file. The module dependencies are determined by the MODULE keyword in NLMLINK. */ - unsigned char moduleDependencyOffset[TARGET_LONG_SIZE]; + unsigned char moduleDependencyOffset[NLM_TARGET_LONG_SIZE]; /* The number of module dependencies at the moduleDependencyOffset. */ - unsigned char numberOfModuleDependencies[TARGET_LONG_SIZE]; + unsigned char numberOfModuleDependencies[NLM_TARGET_LONG_SIZE]; /* The byte offset of the relocation fixup data from the start of the file */ - unsigned char relocationFixupOffset[TARGET_LONG_SIZE]; + unsigned char relocationFixupOffset[NLM_TARGET_LONG_SIZE]; - unsigned char numberOfRelocationFixups[TARGET_LONG_SIZE]; + unsigned char numberOfRelocationFixups[NLM_TARGET_LONG_SIZE]; - unsigned char externalReferencesOffset[TARGET_LONG_SIZE]; + unsigned char externalReferencesOffset[NLM_TARGET_LONG_SIZE]; - unsigned char numberOfExternalReferences[TARGET_LONG_SIZE]; + unsigned char numberOfExternalReferences[NLM_TARGET_LONG_SIZE]; - unsigned char publicsOffset[TARGET_LONG_SIZE]; + unsigned char publicsOffset[NLM_TARGET_LONG_SIZE]; - unsigned char numberOfPublics[TARGET_LONG_SIZE]; + unsigned char numberOfPublics[NLM_TARGET_LONG_SIZE]; /* The byte offset of the internal debug info from the start of the file. It is possible for this to be EOF if there is no debug info. */ - unsigned char debugInfoOffset[TARGET_LONG_SIZE]; + unsigned char debugInfoOffset[NLM_TARGET_LONG_SIZE]; - unsigned char numberOfDebugRecords[TARGET_LONG_SIZE]; + unsigned char numberOfDebugRecords[NLM_TARGET_LONG_SIZE]; - unsigned char codeStartOffset[TARGET_LONG_SIZE]; + unsigned char codeStartOffset[NLM_TARGET_LONG_SIZE]; - unsigned char exitProcedureOffset[TARGET_LONG_SIZE]; + unsigned char exitProcedureOffset[NLM_TARGET_LONG_SIZE]; - unsigned char checkUnloadProcedureOffset[TARGET_LONG_SIZE]; + unsigned char checkUnloadProcedureOffset[NLM_TARGET_LONG_SIZE]; - unsigned char moduleType[TARGET_LONG_SIZE]; + unsigned char moduleType[NLM_TARGET_LONG_SIZE]; - unsigned char flags[TARGET_LONG_SIZE]; + unsigned char flags[NLM_TARGET_LONG_SIZE]; -} Nlm32_External_Fixed_Header; +} NlmNAME(External_Fixed_Header); /* The version header is one of the optional auxiliary headers and follows the fixed length and variable length NLM headers. */ -typedef struct nlm32_external_version_header +typedef struct nlmNAME(external_version_header) { /* The header is recognized by "VeRsIoN#" in the stamp field. */ char stamp[8]; - unsigned char majorVersion[TARGET_LONG_SIZE]; + unsigned char majorVersion[NLM_TARGET_LONG_SIZE]; - unsigned char minorVersion[TARGET_LONG_SIZE]; + unsigned char minorVersion[NLM_TARGET_LONG_SIZE]; - unsigned char revision[TARGET_LONG_SIZE]; + unsigned char revision[NLM_TARGET_LONG_SIZE]; - unsigned char year[TARGET_LONG_SIZE]; + unsigned char year[NLM_TARGET_LONG_SIZE]; - unsigned char month[TARGET_LONG_SIZE]; + unsigned char month[NLM_TARGET_LONG_SIZE]; - unsigned char day[TARGET_LONG_SIZE]; + unsigned char day[NLM_TARGET_LONG_SIZE]; -} Nlm32_External_Version_Header; +} NlmNAME(External_Version_Header); -typedef struct nlm32_external_copyright_header +typedef struct nlmNAME(external_copyright_header) { /* The header is recognized by "CoPyRiGhT=" in the stamp field. */ @@ -176,84 +174,83 @@ typedef struct nlm32_external_copyright_header /* There is a variable length field here called 'copyrightMessage' that is the length specified by copyrightMessageLength. */ -} Nlm32_External_Copyright_Header; +} NlmNAME(External_Copyright_Header); -typedef struct nlm32_external_extended_header +typedef struct nlmNAME(external_extended_header) { /* The header is recognized by "MeSsAgEs" in the stamp field. */ char stamp[8]; - unsigned char languageID[TARGET_LONG_SIZE]; + unsigned char languageID[NLM_TARGET_LONG_SIZE]; - unsigned char messageFileOffset[TARGET_LONG_SIZE]; + unsigned char messageFileOffset[NLM_TARGET_LONG_SIZE]; - unsigned char messageFileLength[TARGET_LONG_SIZE]; + unsigned char messageFileLength[NLM_TARGET_LONG_SIZE]; - unsigned char messageCount[TARGET_LONG_SIZE]; + unsigned char messageCount[NLM_TARGET_LONG_SIZE]; - unsigned char helpFileOffset[TARGET_LONG_SIZE]; + unsigned char helpFileOffset[NLM_TARGET_LONG_SIZE]; - unsigned char helpFileLength[TARGET_LONG_SIZE]; + unsigned char helpFileLength[NLM_TARGET_LONG_SIZE]; - unsigned char RPCDataOffset[TARGET_LONG_SIZE]; + unsigned char RPCDataOffset[NLM_TARGET_LONG_SIZE]; - unsigned char RPCDataLength[TARGET_LONG_SIZE]; + unsigned char RPCDataLength[NLM_TARGET_LONG_SIZE]; - unsigned char sharedCodeOffset[TARGET_LONG_SIZE]; + unsigned char sharedCodeOffset[NLM_TARGET_LONG_SIZE]; - unsigned char sharedCodeLength[TARGET_LONG_SIZE]; + unsigned char sharedCodeLength[NLM_TARGET_LONG_SIZE]; - unsigned char sharedDataOffset[TARGET_LONG_SIZE]; + unsigned char sharedDataOffset[NLM_TARGET_LONG_SIZE]; - unsigned char sharedDataLength[TARGET_LONG_SIZE]; + unsigned char sharedDataLength[NLM_TARGET_LONG_SIZE]; - unsigned char sharedRelocationFixupOffset[TARGET_LONG_SIZE]; + unsigned char sharedRelocationFixupOffset[NLM_TARGET_LONG_SIZE]; - unsigned char sharedRelocationFixupCount[TARGET_LONG_SIZE]; + unsigned char sharedRelocationFixupCount[NLM_TARGET_LONG_SIZE]; - unsigned char sharedExternalReferenceOffset[TARGET_LONG_SIZE]; + unsigned char sharedExternalReferenceOffset[NLM_TARGET_LONG_SIZE]; - unsigned char sharedExternalReferenceCount[TARGET_LONG_SIZE]; + unsigned char sharedExternalReferenceCount[NLM_TARGET_LONG_SIZE]; - unsigned char sharedPublicsOffset[TARGET_LONG_SIZE]; + unsigned char sharedPublicsOffset[NLM_TARGET_LONG_SIZE]; - unsigned char sharedPublicsCount[TARGET_LONG_SIZE]; + unsigned char sharedPublicsCount[NLM_TARGET_LONG_SIZE]; - unsigned char sharedInitializationOffset[TARGET_ADDRESS_SIZE]; + unsigned char sharedInitializationOffset[NLM_TARGET_ADDRESS_SIZE]; - unsigned char SharedExitProcedureOffset[TARGET_ADDRESS_SIZE]; + unsigned char SharedExitProcedureOffset[NLM_TARGET_ADDRESS_SIZE]; - unsigned char productID[TARGET_LONG_SIZE]; + unsigned char productID[NLM_TARGET_LONG_SIZE]; - unsigned char reserved0[TARGET_LONG_SIZE]; + unsigned char reserved0[NLM_TARGET_LONG_SIZE]; - unsigned char reserved1[TARGET_LONG_SIZE]; + unsigned char reserved1[NLM_TARGET_LONG_SIZE]; - unsigned char reserved2[TARGET_LONG_SIZE]; + unsigned char reserved2[NLM_TARGET_LONG_SIZE]; - unsigned char reserved3[TARGET_LONG_SIZE]; + unsigned char reserved3[NLM_TARGET_LONG_SIZE]; - unsigned char reserved4[TARGET_LONG_SIZE]; + unsigned char reserved4[NLM_TARGET_LONG_SIZE]; - unsigned char reserved5[TARGET_LONG_SIZE]; + unsigned char reserved5[NLM_TARGET_LONG_SIZE]; -} Nlm32_External_Extended_Header; +} NlmNAME(External_Extended_Header); -typedef struct nlm32_external_custom_header +typedef struct nlmNAME(external_custom_header) { /* The header is recognized by "CuStHeAd" in the stamp field. */ char stamp[8]; - unsigned char dataLength[TARGET_LONG_SIZE]; - - unsigned char debugRecOffset[TARGET_LONG_SIZE]; + unsigned char dataLength[NLM_TARGET_LONG_SIZE]; - unsigned char debugRecLength[TARGET_LONG_SIZE]; + unsigned char debugRecOffset[NLM_TARGET_LONG_SIZE]; -} Nlm32_External_Custom_Header; + unsigned char debugRecLength[NLM_TARGET_LONG_SIZE]; +} NlmNAME(External_Custom_Header); diff --git a/include/nlm/internal.h b/include/nlm/internal.h new file mode 100644 index 00000000000..48c3d7ef3a6 --- /dev/null +++ b/include/nlm/internal.h @@ -0,0 +1,283 @@ +/* NLM (NetWare Loadable Module) support for BFD. + Copyright (C) 1993 Free Software Foundation, Inc. + + Written by Fred Fish @ Cygnus Support. + +This file is part of BFD, the Binary File Descriptor library. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ + + +/* This file is part of NLM support for BFD, and contains the portions + that describe how NLM is represented internally in the BFD library. + I.E. it describes the in-memory representation of NLM. It requires + the nlm/common.h file which contains the portions that are common to + both the internal and external representations. */ + +#if 0 + +/* Types used by various structures, functions, etc. */ + +typedef unsigned long Nlm32_Addr; /* Unsigned program address */ +typedef unsigned long Nlm32_Off; /* Unsigned file offset */ +typedef long Nlm32_Sword; /* Signed large integer */ +typedef unsigned long Nlm32_Word; /* Unsigned large integer */ +typedef unsigned short Nlm32_Half; /* Unsigned medium integer */ +typedef unsigned char Nlm32_Char; /* Unsigned tiny integer */ + +#ifdef HOST_64_BIT +typedef unsigned HOST_64_BIT Nlm64_Addr; +typedef unsigned HOST_64_BIT Nlm64_Off; +typedef HOST_64_BIT Nlm64_Sxword; +typedef unsigned HOST_64_BIT Nlm64_Xword; +#endif +typedef long Nlm64_Sword; +typedef unsigned long Nlm64_Word; +typedef unsigned short Nlm64_Half; + +#endif /* 0 */ + +/* This structure contains the internal form of the portion of the NLM + header that is fixed length. */ + +typedef struct nlm_internal_fixed_header +{ + /* The signature field identifies the file as an NLM. It must contain + the signature string, which depends upon the NLM target. */ + + char signature[NLM_SIGNATURE_SIZE]; + + /* The version of the header. At this time, the highest version number + is 4. */ + + long version; + + /* The name of the module, which must be a DOS name (1-8 characters followed + by a period and a 1-3 character extension. The first byte is the byte + length of the name and the last byte is a null terminator byte. This + field is fixed length, and any unused bytes should be null bytes. The + value is set by the OUTPUT keyword to NLMLINK. */ + + char moduleName[NLM_MODULE_NAME_SIZE]; + + /* The byte offset of the code image from the start of the file. */ + + file_ptr codeImageOffset; + + /* The size of the code image, in bytes. */ + + bfd_size_type codeImageSize; + + /* The byte offset of the data image from the start of the file. */ + + file_ptr dataImageOffset; + + /* The size of the data image, in bytes. */ + + bfd_size_type dataImageSize; + + /* The size of the uninitialized data region that the loader is to be + allocated at load time. Uninitialized data follows the initialized + data in the NLM address space. */ + + bfd_size_type uninitializedDataSize; + + /* The byte offset of the custom data from the start of the file. The + custom data is set by the CUSTOM keyword to NLMLINK. */ + + file_ptr customDataOffset; + + /* The size of the custom data, in bytes. */ + + bfd_size_type customDataSize; + + /* The byte offset of the module dependencies from the start of the file. + The module dependencies are determined by the MODULE keyword in + NLMLINK. */ + + file_ptr moduleDependencyOffset; + + /* The number of module dependencies at the moduleDependencyOffset. */ + + long numberOfModuleDependencies; + + /* The byte offset of the relocation fixup data from the start of the file */ + + file_ptr relocationFixupOffset; + long numberOfRelocationFixups; + file_ptr externalReferencesOffset; + long numberOfExternalReferences; + file_ptr publicsOffset; + long numberOfPublics; + file_ptr debugInfoOffset; + long numberOfDebugRecords; + file_ptr codeStartOffset; + file_ptr exitProcedureOffset; + file_ptr checkUnloadProcedureOffset; + long moduleType; + long flags; +} Nlm_Internal_Fixed_Header; + +#define nlm32_internal_fixed_header nlm_internal_fixed_header +#define Nlm32_Internal_Fixed_Header Nlm_Internal_Fixed_Header +#define nlm64_internal_fixed_header nlm_internal_fixed_header +#define Nlm64_Internal_Fixed_Header Nlm_Internal_Fixed_Header + +/* This structure contains the portions of the NLM header that are either + variable in size in the external representation, or else are not at a + fixed offset relative to the start of the NLM header due to preceding + variable sized fields. + + Note that all the fields must exist in the external header, and in + the order used here (the same order is used in the internal form + for consistency, not out of necessity). */ + +typedef struct nlm_internal_variable_header +{ + + /* The descriptionLength field contains the length of the text in + descriptionText, excluding the null terminator. The descriptionText + field contains the NLM description obtained from the DESCRIPTION + keyword in NLMLINK plus the null byte terminator. The descriptionText + can be up to NLM_MAX_DESCRIPTION_LENGTH characters. */ + + unsigned char descriptionLength; + char descriptionText[NLM_MAX_DESCRIPTION_LENGTH + 1]; + + /* The stackSize field contains the size of the stack in bytes, as + specified by the STACK or STACKSIZE keyword in NLMLINK. If no size + is specified, the default is NLM_DEFAULT_STACKSIZE. */ + + long stackSize; + + /* The reserved field is included only for completeness. It should contain + zero. */ + + long reserved; + + /* This field is fixed length, should contain " LONG" (note leading + space), and is unused. */ + + char oldThreadName[NLM_OLD_THREAD_NAME_LENGTH]; + + /* The screenNameLength field contains the length of the actual text stored + in the screenName field, excluding the null byte terminator. The + screenName field contains the screen name as specified by the SCREENNAME + keyword in NLMLINK, and can be up to NLM_MAX_SCREEN_NAME_LENGTH + characters. */ + + unsigned char screenNameLength; + char screenName[NLM_MAX_SCREEN_NAME_LENGTH + 1]; + + /* The threadNameLength field contains the length of the actual text stored + in the threadName field, excluding the null byte terminator. The + threadName field contains the thread name as specified by the THREADNAME + keyword in NLMLINK, and can be up to NLM_MAX_THREAD_NAME_LENGTH + characters. */ + + unsigned char threadNameLength; + char threadName[NLM_MAX_THREAD_NAME_LENGTH + 1]; + +} Nlm_Internal_Variable_Header; + +#define nlm32_internal_variable_header nlm_internal_variable_header +#define Nlm32_Internal_Variable_Header Nlm_Internal_Variable_Header +#define nlm64_internal_variable_header nlm_internal_variable_header +#define Nlm64_Internal_Variable_Header Nlm_Internal_Variable_Header + +/* The version header is one of the optional auxiliary headers and + follows the fixed length and variable length NLM headers. */ + +typedef struct nlm_internal_version_header +{ + /* The header is recognized by "VeRsIoN#" in the stamp field. */ + char stamp[8]; + long majorVersion; + long minorVersion; + long revision; + long year; + long month; + long day; +} Nlm_Internal_Version_Header; + +#define nlm32_internal_version_header nlm_internal_version_header +#define Nlm32_Internal_Version_Header Nlm_Internal_Version_Header +#define nlm64_internal_version_header nlm_internal_version_header +#define Nlm64_Internal_Version_Header Nlm_Internal_Version_Header + +typedef struct nlm_internal_copyright_header +{ + /* The header is recognized by "CoPyRiGhT=" in the stamp field. */ + char stamp[10]; + unsigned char copyrightMessageLength; + char copyrightMessage[NLM_MAX_COPYRIGHT_MESSAGE_LENGTH]; +} Nlm_Internal_Copyright_Header; + +#define nlm32_internal_copyright_header nlm_internal_copyright_header +#define Nlm32_Internal_Copyright_Header Nlm_Internal_Copyright_Header +#define nlm64_internal_copyright_header nlm_internal_copyright_header +#define Nlm64_Internal_Copyright_Header Nlm_Internal_Copyright_Header + +typedef struct nlm_internal_extended_header +{ + /* The header is recognized by "MeSsAgEs" in the stamp field. */ + char stamp[8]; + long languageID; + file_ptr messageFileOffset; + bfd_size_type messageFileLength; + long messageCount; + file_ptr helpFileOffset; + bfd_size_type helpFileLength; + file_ptr RPCDataOffset; + bfd_size_type RPCDataLength; + file_ptr sharedCodeOffset; + bfd_size_type sharedCodeLength; + file_ptr sharedDataOffset; + bfd_size_type sharedDataLength; + file_ptr sharedRelocationFixupOffset; + long sharedRelocationFixupCount; + file_ptr sharedExternalReferenceOffset; + long sharedExternalReferenceCount; + file_ptr sharedPublicsOffset; + long sharedPublicsCount; + bfd_vma SharedInitializationOffset; + bfd_vma SharedExitProcedureOffset; + long productID; + long reserved0; + long reserved1; + long reserved2; + long reserved3; + long reserved4; + long reserved5; +} Nlm_Internal_Extended_Header; + +#define nlm32_internal_extended_header nlm_internal_extended_header +#define Nlm32_Internal_Extended_Header Nlm_Internal_Extended_Header +#define nlm64_internal_extended_header nlm_internal_extended_header +#define Nlm64_Internal_Extended_Header Nlm_Internal_Extended_Header + +typedef struct nlm_internal_custom_header +{ + /* The header is recognized by "CuStHeAd" in the stamp field. */ + char stamp[8]; + bfd_size_type dataLength; + file_ptr debugRecOffset; + bfd_size_type debugRecLength; +} Nlm_Internal_Custom_Header; + +#define nlm32_internal_custom_header nlm_internal_custom_header +#define Nlm32_Internal_Custom_Header Nlm_Internal_Custom_Header +#define nlm64_internal_custom_header nlm_internal_custom_header +#define Nlm64_Internal_Custom_Header Nlm_Internal_Custom_Header -- 2.30.2