Update the FSF address in the copyright/GPL notice
[deliverable/binutils-gdb.git] / bfd / nlmswap.h
CommitLineData
252b5132 1/* NLM (NetWare Loadable Module) swapping routines for BFD.
7920ce38 2 Copyright 1993, 2000, 2001, 2005 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
11 the Free Software Foundation; either version 2 of the License, or
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
53e09e0a 21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02110-1301, USA. */
252b5132
RH
22
23/* Although this is a header file, it defines functions. It is
24 included by NLM backends to define swapping functions that vary
25 from one NLM to another. The backend code must arrange for
26 Nlm_External_xxxx to be defined appropriately, and can then include
27 this file to get the swapping routines.
28
29 At the moment this is only needed for one structure, the fixed NLM
30 file header. */
31
252b5132 32/* Translate an NLM fixed length file header in external format into an NLM
1518639e 33 file header in internal format. */
252b5132
RH
34
35static void
7920ce38
NC
36nlm_swap_fixed_header_in (bfd *abfd,
37 void * realsrc,
38 Nlm_Internal_Fixed_Header *dst)
252b5132
RH
39{
40 Nlm_External_Fixed_Header *src = (Nlm_External_Fixed_Header *) realsrc;
7920ce38 41
252b5132
RH
42 memcpy (dst->signature, src->signature, NLM_SIGNATURE_SIZE);
43 memcpy (dst->moduleName, src->moduleName, NLM_MODULE_NAME_SIZE);
44 dst->version =
dc810e39 45 H_GET_32 (abfd, src->version);
252b5132 46 dst->codeImageOffset =
dc810e39 47 H_GET_32 (abfd, src->codeImageOffset);
252b5132 48 dst->codeImageSize =
dc810e39 49 H_GET_32 (abfd, src->codeImageSize);
252b5132 50 dst->dataImageOffset =
dc810e39 51 H_GET_32 (abfd, src->dataImageOffset);
252b5132 52 dst->dataImageSize =
dc810e39 53 H_GET_32 (abfd, src->dataImageSize);
252b5132 54 dst->uninitializedDataSize =
dc810e39 55 H_GET_32 (abfd, src->uninitializedDataSize);
252b5132 56 dst->customDataOffset =
dc810e39 57 H_GET_32 (abfd, src->customDataOffset);
252b5132 58 dst->customDataSize =
dc810e39 59 H_GET_32 (abfd, src->customDataSize);
252b5132 60 dst->moduleDependencyOffset =
dc810e39 61 H_GET_32 (abfd, src->moduleDependencyOffset);
252b5132 62 dst->numberOfModuleDependencies =
dc810e39 63 H_GET_32 (abfd, src->numberOfModuleDependencies);
252b5132 64 dst->relocationFixupOffset =
dc810e39 65 H_GET_32 (abfd, src->relocationFixupOffset);
252b5132 66 dst->numberOfRelocationFixups =
dc810e39 67 H_GET_32 (abfd, src->numberOfRelocationFixups);
252b5132 68 dst->externalReferencesOffset =
dc810e39 69 H_GET_32 (abfd, src->externalReferencesOffset);
252b5132 70 dst->numberOfExternalReferences =
dc810e39 71 H_GET_32 (abfd, src->numberOfExternalReferences);
252b5132 72 dst->publicsOffset =
dc810e39 73 H_GET_32 (abfd, src->publicsOffset);
252b5132 74 dst->numberOfPublics =
dc810e39 75 H_GET_32 (abfd, src->numberOfPublics);
252b5132 76 dst->debugInfoOffset =
dc810e39 77 H_GET_32 (abfd, src->debugInfoOffset);
252b5132 78 dst->numberOfDebugRecords =
dc810e39 79 H_GET_32 (abfd, src->numberOfDebugRecords);
252b5132 80 dst->codeStartOffset =
dc810e39 81 H_GET_32 (abfd, src->codeStartOffset);
252b5132 82 dst->exitProcedureOffset =
dc810e39 83 H_GET_32 (abfd, src->exitProcedureOffset);
252b5132 84 dst->checkUnloadProcedureOffset =
dc810e39 85 H_GET_32 (abfd, src->checkUnloadProcedureOffset);
252b5132 86 dst->moduleType =
dc810e39 87 H_GET_32 (abfd, src->moduleType);
252b5132 88 dst->flags =
dc810e39 89 H_GET_32 (abfd, src->flags);
252b5132
RH
90}
91
92/* Translate an NLM fixed length file header in internal format into
1518639e 93 an NLM file header in external format. */
252b5132
RH
94
95static void
7920ce38
NC
96nlm_swap_fixed_header_out (bfd *abfd,
97 Nlm_Internal_Fixed_Header *src,
98 void * realdst)
252b5132
RH
99{
100 Nlm_External_Fixed_Header *dst = (Nlm_External_Fixed_Header *) realdst;
7920ce38 101
252b5132
RH
102 memset (dst, 0, sizeof *dst);
103 memcpy (dst->signature, src->signature, NLM_SIGNATURE_SIZE);
104 memcpy (dst->moduleName, src->moduleName, NLM_MODULE_NAME_SIZE);
dc810e39
AM
105 H_PUT_32 (abfd, src->version,
106 dst->version);
107 H_PUT_32 (abfd, src->codeImageOffset,
108 dst->codeImageOffset);
109 H_PUT_32 (abfd, src->codeImageSize,
110 dst->codeImageSize);
111 H_PUT_32 (abfd, src->dataImageOffset,
112 dst->dataImageOffset);
113 H_PUT_32 (abfd, src->dataImageSize,
114 dst->dataImageSize);
115 H_PUT_32 (abfd, src->uninitializedDataSize,
116 dst->uninitializedDataSize);
117 H_PUT_32 (abfd, src->customDataOffset,
118 dst->customDataOffset);
119 H_PUT_32 (abfd, src->customDataSize,
120 dst->customDataSize);
121 H_PUT_32 (abfd, src->moduleDependencyOffset,
122 dst->moduleDependencyOffset);
123 H_PUT_32 (abfd, src->numberOfModuleDependencies,
124 dst->numberOfModuleDependencies);
125 H_PUT_32 (abfd, src->relocationFixupOffset,
126 dst->relocationFixupOffset);
127 H_PUT_32 (abfd, src->numberOfRelocationFixups,
128 dst->numberOfRelocationFixups);
129 H_PUT_32 (abfd, src->externalReferencesOffset,
130 dst->externalReferencesOffset);
131 H_PUT_32 (abfd, src->numberOfExternalReferences,
132 dst->numberOfExternalReferences);
133 H_PUT_32 (abfd, src->publicsOffset,
134 dst->publicsOffset);
135 H_PUT_32 (abfd, src->numberOfPublics,
136 dst->numberOfPublics);
137 H_PUT_32 (abfd, src->debugInfoOffset,
138 dst->debugInfoOffset);
139 H_PUT_32 (abfd, src->numberOfDebugRecords,
140 dst->numberOfDebugRecords);
141 H_PUT_32 (abfd, src->codeStartOffset,
142 dst->codeStartOffset);
143 H_PUT_32 (abfd, src->exitProcedureOffset,
144 dst->exitProcedureOffset);
145 H_PUT_32 (abfd, src->checkUnloadProcedureOffset,
146 dst->checkUnloadProcedureOffset);
147 H_PUT_32 (abfd, src->moduleType,
148 dst->moduleType);
149 H_PUT_32 (abfd, src->flags,
150 dst->flags);
252b5132 151}
This page took 0.304499 seconds and 4 git commands to generate.