daily update
[deliverable/binutils-gdb.git] / bfd / nlmswap.h
1 /* NLM (NetWare Loadable Module) swapping routines for BFD.
2 Copyright 1993, 2000, 2001 Free Software Foundation, Inc.
3
4 Written by Fred Fish @ Cygnus Support, using ELF support as the
5 template.
6
7 This file is part of BFD, the Binary File Descriptor library.
8
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.
13
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.
18
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
21 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
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
32 static void nlm_swap_fixed_header_in PARAMS ((bfd *, PTR,
33 Nlm_Internal_Fixed_Header *));
34 static void nlm_swap_fixed_header_out PARAMS ((bfd *,
35 Nlm_Internal_Fixed_Header *,
36 PTR));
37
38 /* Translate an NLM fixed length file header in external format into an NLM
39 file header in internal format. */
40
41 static void
42 nlm_swap_fixed_header_in (abfd, realsrc, dst)
43 bfd *abfd;
44 PTR realsrc;
45 Nlm_Internal_Fixed_Header *dst;
46 {
47 Nlm_External_Fixed_Header *src = (Nlm_External_Fixed_Header *) realsrc;
48 memcpy (dst->signature, src->signature, NLM_SIGNATURE_SIZE);
49 memcpy (dst->moduleName, src->moduleName, NLM_MODULE_NAME_SIZE);
50 dst->version =
51 H_GET_32 (abfd, src->version);
52 dst->codeImageOffset =
53 H_GET_32 (abfd, src->codeImageOffset);
54 dst->codeImageSize =
55 H_GET_32 (abfd, src->codeImageSize);
56 dst->dataImageOffset =
57 H_GET_32 (abfd, src->dataImageOffset);
58 dst->dataImageSize =
59 H_GET_32 (abfd, src->dataImageSize);
60 dst->uninitializedDataSize =
61 H_GET_32 (abfd, src->uninitializedDataSize);
62 dst->customDataOffset =
63 H_GET_32 (abfd, src->customDataOffset);
64 dst->customDataSize =
65 H_GET_32 (abfd, src->customDataSize);
66 dst->moduleDependencyOffset =
67 H_GET_32 (abfd, src->moduleDependencyOffset);
68 dst->numberOfModuleDependencies =
69 H_GET_32 (abfd, src->numberOfModuleDependencies);
70 dst->relocationFixupOffset =
71 H_GET_32 (abfd, src->relocationFixupOffset);
72 dst->numberOfRelocationFixups =
73 H_GET_32 (abfd, src->numberOfRelocationFixups);
74 dst->externalReferencesOffset =
75 H_GET_32 (abfd, src->externalReferencesOffset);
76 dst->numberOfExternalReferences =
77 H_GET_32 (abfd, src->numberOfExternalReferences);
78 dst->publicsOffset =
79 H_GET_32 (abfd, src->publicsOffset);
80 dst->numberOfPublics =
81 H_GET_32 (abfd, src->numberOfPublics);
82 dst->debugInfoOffset =
83 H_GET_32 (abfd, src->debugInfoOffset);
84 dst->numberOfDebugRecords =
85 H_GET_32 (abfd, src->numberOfDebugRecords);
86 dst->codeStartOffset =
87 H_GET_32 (abfd, src->codeStartOffset);
88 dst->exitProcedureOffset =
89 H_GET_32 (abfd, src->exitProcedureOffset);
90 dst->checkUnloadProcedureOffset =
91 H_GET_32 (abfd, src->checkUnloadProcedureOffset);
92 dst->moduleType =
93 H_GET_32 (abfd, src->moduleType);
94 dst->flags =
95 H_GET_32 (abfd, src->flags);
96 }
97
98 /* Translate an NLM fixed length file header in internal format into
99 an NLM file header in external format. */
100
101 static void
102 nlm_swap_fixed_header_out (abfd, src, realdst)
103 bfd *abfd;
104 Nlm_Internal_Fixed_Header *src;
105 PTR realdst;
106 {
107 Nlm_External_Fixed_Header *dst = (Nlm_External_Fixed_Header *) realdst;
108 memset (dst, 0, sizeof *dst);
109 memcpy (dst->signature, src->signature, NLM_SIGNATURE_SIZE);
110 memcpy (dst->moduleName, src->moduleName, NLM_MODULE_NAME_SIZE);
111 H_PUT_32 (abfd, src->version,
112 dst->version);
113 H_PUT_32 (abfd, src->codeImageOffset,
114 dst->codeImageOffset);
115 H_PUT_32 (abfd, src->codeImageSize,
116 dst->codeImageSize);
117 H_PUT_32 (abfd, src->dataImageOffset,
118 dst->dataImageOffset);
119 H_PUT_32 (abfd, src->dataImageSize,
120 dst->dataImageSize);
121 H_PUT_32 (abfd, src->uninitializedDataSize,
122 dst->uninitializedDataSize);
123 H_PUT_32 (abfd, src->customDataOffset,
124 dst->customDataOffset);
125 H_PUT_32 (abfd, src->customDataSize,
126 dst->customDataSize);
127 H_PUT_32 (abfd, src->moduleDependencyOffset,
128 dst->moduleDependencyOffset);
129 H_PUT_32 (abfd, src->numberOfModuleDependencies,
130 dst->numberOfModuleDependencies);
131 H_PUT_32 (abfd, src->relocationFixupOffset,
132 dst->relocationFixupOffset);
133 H_PUT_32 (abfd, src->numberOfRelocationFixups,
134 dst->numberOfRelocationFixups);
135 H_PUT_32 (abfd, src->externalReferencesOffset,
136 dst->externalReferencesOffset);
137 H_PUT_32 (abfd, src->numberOfExternalReferences,
138 dst->numberOfExternalReferences);
139 H_PUT_32 (abfd, src->publicsOffset,
140 dst->publicsOffset);
141 H_PUT_32 (abfd, src->numberOfPublics,
142 dst->numberOfPublics);
143 H_PUT_32 (abfd, src->debugInfoOffset,
144 dst->debugInfoOffset);
145 H_PUT_32 (abfd, src->numberOfDebugRecords,
146 dst->numberOfDebugRecords);
147 H_PUT_32 (abfd, src->codeStartOffset,
148 dst->codeStartOffset);
149 H_PUT_32 (abfd, src->exitProcedureOffset,
150 dst->exitProcedureOffset);
151 H_PUT_32 (abfd, src->checkUnloadProcedureOffset,
152 dst->checkUnloadProcedureOffset);
153 H_PUT_32 (abfd, src->moduleType,
154 dst->moduleType);
155 H_PUT_32 (abfd, src->flags,
156 dst->flags);
157 }
This page took 0.041117 seconds and 4 git commands to generate.