binutils-gdb/bfd/nlmswap.h

158 lines
5.7 KiB
C
Raw Normal View History

1999-05-03 15:29:11 +08:00
/* NLM (NetWare Loadable Module) swapping routines for BFD.
Copyright 1993, 2000, 2001 Free Software Foundation, Inc.
1999-05-03 15:29:11 +08:00
Written by Fred Fish @ Cygnus Support, using ELF support as the
template.
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
/* Although this is a header file, it defines functions. It is
included by NLM backends to define swapping functions that vary
from one NLM to another. The backend code must arrange for
Nlm_External_xxxx to be defined appropriately, and can then include
this file to get the swapping routines.
At the moment this is only needed for one structure, the fixed NLM
file header. */
static void nlm_swap_fixed_header_in PARAMS ((bfd *, PTR,
Nlm_Internal_Fixed_Header *));
static void nlm_swap_fixed_header_out PARAMS ((bfd *,
Nlm_Internal_Fixed_Header *,
PTR));
/* Translate an NLM fixed length file header in external format into an NLM
file header in internal format. */
1999-05-03 15:29:11 +08:00
static void
nlm_swap_fixed_header_in (abfd, realsrc, dst)
bfd *abfd;
PTR realsrc;
Nlm_Internal_Fixed_Header *dst;
{
Nlm_External_Fixed_Header *src = (Nlm_External_Fixed_Header *) realsrc;
memcpy (dst->signature, src->signature, NLM_SIGNATURE_SIZE);
memcpy (dst->moduleName, src->moduleName, NLM_MODULE_NAME_SIZE);
dst->version =
H_GET_32 (abfd, src->version);
1999-05-03 15:29:11 +08:00
dst->codeImageOffset =
H_GET_32 (abfd, src->codeImageOffset);
1999-05-03 15:29:11 +08:00
dst->codeImageSize =
H_GET_32 (abfd, src->codeImageSize);
1999-05-03 15:29:11 +08:00
dst->dataImageOffset =
H_GET_32 (abfd, src->dataImageOffset);
1999-05-03 15:29:11 +08:00
dst->dataImageSize =
H_GET_32 (abfd, src->dataImageSize);
1999-05-03 15:29:11 +08:00
dst->uninitializedDataSize =
H_GET_32 (abfd, src->uninitializedDataSize);
1999-05-03 15:29:11 +08:00
dst->customDataOffset =
H_GET_32 (abfd, src->customDataOffset);
1999-05-03 15:29:11 +08:00
dst->customDataSize =
H_GET_32 (abfd, src->customDataSize);
1999-05-03 15:29:11 +08:00
dst->moduleDependencyOffset =
H_GET_32 (abfd, src->moduleDependencyOffset);
1999-05-03 15:29:11 +08:00
dst->numberOfModuleDependencies =
H_GET_32 (abfd, src->numberOfModuleDependencies);
1999-05-03 15:29:11 +08:00
dst->relocationFixupOffset =
H_GET_32 (abfd, src->relocationFixupOffset);
1999-05-03 15:29:11 +08:00
dst->numberOfRelocationFixups =
H_GET_32 (abfd, src->numberOfRelocationFixups);
1999-05-03 15:29:11 +08:00
dst->externalReferencesOffset =
H_GET_32 (abfd, src->externalReferencesOffset);
1999-05-03 15:29:11 +08:00
dst->numberOfExternalReferences =
H_GET_32 (abfd, src->numberOfExternalReferences);
1999-05-03 15:29:11 +08:00
dst->publicsOffset =
H_GET_32 (abfd, src->publicsOffset);
1999-05-03 15:29:11 +08:00
dst->numberOfPublics =
H_GET_32 (abfd, src->numberOfPublics);
1999-05-03 15:29:11 +08:00
dst->debugInfoOffset =
H_GET_32 (abfd, src->debugInfoOffset);
1999-05-03 15:29:11 +08:00
dst->numberOfDebugRecords =
H_GET_32 (abfd, src->numberOfDebugRecords);
1999-05-03 15:29:11 +08:00
dst->codeStartOffset =
H_GET_32 (abfd, src->codeStartOffset);
1999-05-03 15:29:11 +08:00
dst->exitProcedureOffset =
H_GET_32 (abfd, src->exitProcedureOffset);
1999-05-03 15:29:11 +08:00
dst->checkUnloadProcedureOffset =
H_GET_32 (abfd, src->checkUnloadProcedureOffset);
1999-05-03 15:29:11 +08:00
dst->moduleType =
H_GET_32 (abfd, src->moduleType);
1999-05-03 15:29:11 +08:00
dst->flags =
H_GET_32 (abfd, src->flags);
1999-05-03 15:29:11 +08:00
}
/* Translate an NLM fixed length file header in internal format into
an NLM file header in external format. */
1999-05-03 15:29:11 +08:00
static void
nlm_swap_fixed_header_out (abfd, src, realdst)
bfd *abfd;
Nlm_Internal_Fixed_Header *src;
PTR realdst;
{
Nlm_External_Fixed_Header *dst = (Nlm_External_Fixed_Header *) realdst;
memset (dst, 0, sizeof *dst);
memcpy (dst->signature, src->signature, NLM_SIGNATURE_SIZE);
memcpy (dst->moduleName, src->moduleName, NLM_MODULE_NAME_SIZE);
H_PUT_32 (abfd, src->version,
dst->version);
H_PUT_32 (abfd, src->codeImageOffset,
dst->codeImageOffset);
H_PUT_32 (abfd, src->codeImageSize,
dst->codeImageSize);
H_PUT_32 (abfd, src->dataImageOffset,
dst->dataImageOffset);
H_PUT_32 (abfd, src->dataImageSize,
dst->dataImageSize);
H_PUT_32 (abfd, src->uninitializedDataSize,
dst->uninitializedDataSize);
H_PUT_32 (abfd, src->customDataOffset,
dst->customDataOffset);
H_PUT_32 (abfd, src->customDataSize,
dst->customDataSize);
H_PUT_32 (abfd, src->moduleDependencyOffset,
dst->moduleDependencyOffset);
H_PUT_32 (abfd, src->numberOfModuleDependencies,
dst->numberOfModuleDependencies);
H_PUT_32 (abfd, src->relocationFixupOffset,
dst->relocationFixupOffset);
H_PUT_32 (abfd, src->numberOfRelocationFixups,
dst->numberOfRelocationFixups);
H_PUT_32 (abfd, src->externalReferencesOffset,
dst->externalReferencesOffset);
H_PUT_32 (abfd, src->numberOfExternalReferences,
dst->numberOfExternalReferences);
H_PUT_32 (abfd, src->publicsOffset,
dst->publicsOffset);
H_PUT_32 (abfd, src->numberOfPublics,
dst->numberOfPublics);
H_PUT_32 (abfd, src->debugInfoOffset,
dst->debugInfoOffset);
H_PUT_32 (abfd, src->numberOfDebugRecords,
dst->numberOfDebugRecords);
H_PUT_32 (abfd, src->codeStartOffset,
dst->codeStartOffset);
H_PUT_32 (abfd, src->exitProcedureOffset,
dst->exitProcedureOffset);
H_PUT_32 (abfd, src->checkUnloadProcedureOffset,
dst->checkUnloadProcedureOffset);
H_PUT_32 (abfd, src->moduleType,
dst->moduleType);
H_PUT_32 (abfd, src->flags,
dst->flags);
1999-05-03 15:29:11 +08:00
}