*** empty log message ***
[deliverable/binutils-gdb.git] / bfd / nlmswap.h
CommitLineData
252b5132 1/* NLM (NetWare Loadable Module) swapping routines for BFD.
cd123cb7 2 Copyright 1993, 2000, 2001, 2005, 2007 Free Software Foundation, Inc.
252b5132
RH
3
4 Written by Fred Fish @ Cygnus Support, using ELF support as the
5 template.
6
7920ce38 7 This file is part of BFD, the Binary File Descriptor library.
252b5132 8
7920ce38
NC
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
cd123cb7 11 the Free Software Foundation; either version 3 of the License, or
7920ce38 12 (at your option) any later version.
252b5132 13
7920ce38
NC
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
252b5132 18
7920ce38
NC
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
cd123cb7
NC
21 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
22 MA 02110-1301, USA. */
23
252b5132
RH
24
25/* Although this is a header file, it defines functions. It is
26 included by NLM backends to define swapping functions that vary
27 from one NLM to another. The backend code must arrange for
28 Nlm_External_xxxx to be defined appropriately, and can then include
29 this file to get the swapping routines.
30
31 At the moment this is only needed for one structure, the fixed NLM
32 file header. */
33
252b5132 34/* Translate an NLM fixed length file header in external format into an NLM
1518639e 35 file header in internal format. */
252b5132
RH
36
37static void
7920ce38
NC
38nlm_swap_fixed_header_in (bfd *abfd,
39 void * realsrc,
40 Nlm_Internal_Fixed_Header *dst)
252b5132
RH
41{
42 Nlm_External_Fixed_Header *src = (Nlm_External_Fixed_Header *) realsrc;
7920ce38 43
252b5132
RH
44 memcpy (dst->signature, src->signature, NLM_SIGNATURE_SIZE);
45 memcpy (dst->moduleName, src->moduleName, NLM_MODULE_NAME_SIZE);
46 dst->version =
dc810e39 47 H_GET_32 (abfd, src->version);
252b5132 48 dst->codeImageOffset =
dc810e39 49 H_GET_32 (abfd, src->codeImageOffset);
252b5132 50 dst->codeImageSize =
dc810e39 51 H_GET_32 (abfd, src->codeImageSize);
252b5132 52 dst->dataImageOffset =
dc810e39 53 H_GET_32 (abfd, src->dataImageOffset);
252b5132 54 dst->dataImageSize =
dc810e39 55 H_GET_32 (abfd, src->dataImageSize);
252b5132 56 dst->uninitializedDataSize =
dc810e39 57 H_GET_32 (abfd, src->uninitializedDataSize);
252b5132 58 dst->customDataOffset =
dc810e39 59 H_GET_32 (abfd, src->customDataOffset);
252b5132 60 dst->customDataSize =
dc810e39 61 H_GET_32 (abfd, src->customDataSize);
252b5132 62 dst->moduleDependencyOffset =
dc810e39 63 H_GET_32 (abfd, src->moduleDependencyOffset);
252b5132 64 dst->numberOfModuleDependencies =
dc810e39 65 H_GET_32 (abfd, src->numberOfModuleDependencies);
252b5132 66 dst->relocationFixupOffset =
dc810e39 67 H_GET_32 (abfd, src->relocationFixupOffset);
252b5132 68 dst->numberOfRelocationFixups =
dc810e39 69 H_GET_32 (abfd, src->numberOfRelocationFixups);
252b5132 70 dst->externalReferencesOffset =
dc810e39 71 H_GET_32 (abfd, src->externalReferencesOffset);
252b5132 72 dst->numberOfExternalReferences =
dc810e39 73 H_GET_32 (abfd, src->numberOfExternalReferences);
252b5132 74 dst->publicsOffset =
dc810e39 75 H_GET_32 (abfd, src->publicsOffset);
252b5132 76 dst->numberOfPublics =
dc810e39 77 H_GET_32 (abfd, src->numberOfPublics);
252b5132 78 dst->debugInfoOffset =
dc810e39 79 H_GET_32 (abfd, src->debugInfoOffset);
252b5132 80 dst->numberOfDebugRecords =
dc810e39 81 H_GET_32 (abfd, src->numberOfDebugRecords);
252b5132 82 dst->codeStartOffset =
dc810e39 83 H_GET_32 (abfd, src->codeStartOffset);
252b5132 84 dst->exitProcedureOffset =
dc810e39 85 H_GET_32 (abfd, src->exitProcedureOffset);
252b5132 86 dst->checkUnloadProcedureOffset =
dc810e39 87 H_GET_32 (abfd, src->checkUnloadProcedureOffset);
252b5132 88 dst->moduleType =
dc810e39 89 H_GET_32 (abfd, src->moduleType);
252b5132 90 dst->flags =
dc810e39 91 H_GET_32 (abfd, src->flags);
252b5132
RH
92}
93
94/* Translate an NLM fixed length file header in internal format into
1518639e 95 an NLM file header in external format. */
252b5132
RH
96
97static void
7920ce38
NC
98nlm_swap_fixed_header_out (bfd *abfd,
99 Nlm_Internal_Fixed_Header *src,
100 void * realdst)
252b5132
RH
101{
102 Nlm_External_Fixed_Header *dst = (Nlm_External_Fixed_Header *) realdst;
7920ce38 103
252b5132
RH
104 memset (dst, 0, sizeof *dst);
105 memcpy (dst->signature, src->signature, NLM_SIGNATURE_SIZE);
106 memcpy (dst->moduleName, src->moduleName, NLM_MODULE_NAME_SIZE);
dc810e39
AM
107 H_PUT_32 (abfd, src->version,
108 dst->version);
109 H_PUT_32 (abfd, src->codeImageOffset,
110 dst->codeImageOffset);
111 H_PUT_32 (abfd, src->codeImageSize,
112 dst->codeImageSize);
113 H_PUT_32 (abfd, src->dataImageOffset,
114 dst->dataImageOffset);
115 H_PUT_32 (abfd, src->dataImageSize,
116 dst->dataImageSize);
117 H_PUT_32 (abfd, src->uninitializedDataSize,
118 dst->uninitializedDataSize);
119 H_PUT_32 (abfd, src->customDataOffset,
120 dst->customDataOffset);
121 H_PUT_32 (abfd, src->customDataSize,
122 dst->customDataSize);
123 H_PUT_32 (abfd, src->moduleDependencyOffset,
124 dst->moduleDependencyOffset);
125 H_PUT_32 (abfd, src->numberOfModuleDependencies,
126 dst->numberOfModuleDependencies);
127 H_PUT_32 (abfd, src->relocationFixupOffset,
128 dst->relocationFixupOffset);
129 H_PUT_32 (abfd, src->numberOfRelocationFixups,
130 dst->numberOfRelocationFixups);
131 H_PUT_32 (abfd, src->externalReferencesOffset,
132 dst->externalReferencesOffset);
133 H_PUT_32 (abfd, src->numberOfExternalReferences,
134 dst->numberOfExternalReferences);
135 H_PUT_32 (abfd, src->publicsOffset,
136 dst->publicsOffset);
137 H_PUT_32 (abfd, src->numberOfPublics,
138 dst->numberOfPublics);
139 H_PUT_32 (abfd, src->debugInfoOffset,
140 dst->debugInfoOffset);
141 H_PUT_32 (abfd, src->numberOfDebugRecords,
142 dst->numberOfDebugRecords);
143 H_PUT_32 (abfd, src->codeStartOffset,
144 dst->codeStartOffset);
145 H_PUT_32 (abfd, src->exitProcedureOffset,
146 dst->exitProcedureOffset);
147 H_PUT_32 (abfd, src->checkUnloadProcedureOffset,
148 dst->checkUnloadProcedureOffset);
149 H_PUT_32 (abfd, src->moduleType,
150 dst->moduleType);
151 H_PUT_32 (abfd, src->flags,
152 dst->flags);
252b5132 153}
This page took 0.577459 seconds and 4 git commands to generate.