Added copyright notice and comments.
[deliverable/binutils-gdb.git] / bfd / nlmswap.h
1 /* NLM (NetWare Loadable Module) swapping routines for BFD.
2 Copyright (C) 1993 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., 675 Mass Ave, Cambridge, MA 02139, 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 /* Translate an NLM fixed length file header in external format into an NLM
33 file header in internal format. */
34
35 static void
36 DEFUN (nlm_swap_fixed_header_in, (abfd, realsrc, dst),
37 bfd * abfd AND
38 PTR realsrc AND
39 Nlm_Internal_Fixed_Header * dst)
40 {
41 Nlm_External_Fixed_Header *src = (Nlm_External_Fixed_Header*)realsrc;
42 memcpy (dst -> signature, src -> signature, NLM_SIGNATURE_SIZE);
43 memcpy (dst -> moduleName, src -> moduleName, NLM_MODULE_NAME_SIZE);
44 dst -> version =
45 bfd_h_get_32 (abfd, (bfd_byte *) src -> version);
46 dst -> codeImageOffset =
47 bfd_h_get_32 (abfd, (bfd_byte *) src -> codeImageOffset);
48 dst -> codeImageSize =
49 bfd_h_get_32 (abfd, (bfd_byte *) src -> codeImageSize);
50 dst -> dataImageOffset =
51 bfd_h_get_32 (abfd, (bfd_byte *) src -> dataImageOffset);
52 dst -> dataImageSize =
53 bfd_h_get_32 (abfd, (bfd_byte *) src -> dataImageSize);
54 dst -> uninitializedDataSize =
55 bfd_h_get_32 (abfd, (bfd_byte *) src -> uninitializedDataSize);
56 dst -> customDataOffset =
57 bfd_h_get_32 (abfd, (bfd_byte *) src -> customDataOffset);
58 dst -> customDataSize =
59 bfd_h_get_32 (abfd, (bfd_byte *) src -> customDataSize);
60 dst -> moduleDependencyOffset =
61 bfd_h_get_32 (abfd, (bfd_byte *) src -> moduleDependencyOffset);
62 dst -> numberOfModuleDependencies =
63 bfd_h_get_32 (abfd, (bfd_byte *) src -> numberOfModuleDependencies);
64 dst -> relocationFixupOffset =
65 bfd_h_get_32 (abfd, (bfd_byte *) src -> relocationFixupOffset);
66 dst -> numberOfRelocationFixups =
67 bfd_h_get_32 (abfd, (bfd_byte *) src -> numberOfRelocationFixups);
68 dst -> externalReferencesOffset =
69 bfd_h_get_32 (abfd, (bfd_byte *) src -> externalReferencesOffset);
70 dst -> numberOfExternalReferences =
71 bfd_h_get_32 (abfd, (bfd_byte *) src -> numberOfExternalReferences);
72 dst -> publicsOffset =
73 bfd_h_get_32 (abfd, (bfd_byte *) src -> publicsOffset);
74 dst -> numberOfPublics =
75 bfd_h_get_32 (abfd, (bfd_byte *) src -> numberOfPublics);
76 dst -> debugInfoOffset =
77 bfd_h_get_32 (abfd, (bfd_byte *) src -> debugInfoOffset);
78 dst -> numberOfDebugRecords =
79 bfd_h_get_32 (abfd, (bfd_byte *) src -> numberOfDebugRecords);
80 dst -> codeStartOffset =
81 bfd_h_get_32 (abfd, (bfd_byte *) src -> codeStartOffset);
82 dst -> exitProcedureOffset =
83 bfd_h_get_32 (abfd, (bfd_byte *) src -> exitProcedureOffset);
84 dst -> checkUnloadProcedureOffset =
85 bfd_h_get_32 (abfd, (bfd_byte *) src -> checkUnloadProcedureOffset);
86 dst -> moduleType =
87 bfd_h_get_32 (abfd, (bfd_byte *) src -> moduleType);
88 dst -> flags =
89 bfd_h_get_32 (abfd, (bfd_byte *) src -> flags);
90 }
91
92 /* Translate an NLM fixed length file header in internal format into
93 an NLM file header in external format. */
94
95 static void
96 DEFUN (nlm_swap_fixed_header_out, (abfd, src, realdst),
97 bfd * abfd AND
98 Nlm_Internal_Fixed_Header * src AND
99 PTR realdst)
100 {
101 Nlm_External_Fixed_Header * dst = (Nlm_External_Fixed_Header*)realdst;
102 memcpy (dst -> signature, src -> signature, NLM_SIGNATURE_SIZE);
103 memcpy (dst -> moduleName, src -> moduleName, NLM_MODULE_NAME_SIZE);
104 bfd_h_put_32 (abfd, (bfd_vma) src -> version,
105 (bfd_byte *) dst -> version);
106 bfd_h_put_32 (abfd, (bfd_vma) src -> codeImageOffset,
107 (bfd_byte *) dst -> codeImageOffset);
108 bfd_h_put_32 (abfd, (bfd_vma) src -> codeImageSize,
109 (bfd_byte *) dst -> codeImageSize);
110 bfd_h_put_32 (abfd, (bfd_vma) src -> dataImageOffset,
111 (bfd_byte *) dst -> dataImageOffset);
112 bfd_h_put_32 (abfd, (bfd_vma) src -> dataImageSize,
113 (bfd_byte *) dst -> dataImageSize);
114 bfd_h_put_32 (abfd, (bfd_vma) src -> uninitializedDataSize,
115 (bfd_byte *) dst -> uninitializedDataSize);
116 bfd_h_put_32 (abfd, (bfd_vma) src -> customDataOffset,
117 (bfd_byte *) dst -> customDataOffset);
118 bfd_h_put_32 (abfd, (bfd_vma) src -> customDataSize,
119 (bfd_byte *) dst -> customDataSize);
120 bfd_h_put_32 (abfd, (bfd_vma) src -> moduleDependencyOffset,
121 (bfd_byte *) dst -> moduleDependencyOffset);
122 bfd_h_put_32 (abfd, (bfd_vma) src -> numberOfModuleDependencies,
123 (bfd_byte *) dst -> numberOfModuleDependencies);
124 bfd_h_put_32 (abfd, (bfd_vma) src -> relocationFixupOffset,
125 (bfd_byte *) dst -> relocationFixupOffset);
126 bfd_h_put_32 (abfd, (bfd_vma) src -> numberOfRelocationFixups,
127 (bfd_byte *) dst -> numberOfRelocationFixups);
128 bfd_h_put_32 (abfd, (bfd_vma) src -> externalReferencesOffset,
129 (bfd_byte *) dst -> externalReferencesOffset);
130 bfd_h_put_32 (abfd, (bfd_vma) src -> numberOfExternalReferences,
131 (bfd_byte *) dst -> numberOfExternalReferences);
132 bfd_h_put_32 (abfd, (bfd_vma) src -> publicsOffset,
133 (bfd_byte *) dst -> publicsOffset);
134 bfd_h_put_32 (abfd, (bfd_vma) src -> numberOfPublics,
135 (bfd_byte *) dst -> numberOfPublics);
136 bfd_h_put_32 (abfd, (bfd_vma) src -> debugInfoOffset,
137 (bfd_byte *) dst -> debugInfoOffset);
138 bfd_h_put_32 (abfd, (bfd_vma) src -> numberOfDebugRecords,
139 (bfd_byte *) dst -> numberOfDebugRecords);
140 bfd_h_put_32 (abfd, (bfd_vma) src -> codeStartOffset,
141 (bfd_byte *) dst -> codeStartOffset);
142 bfd_h_put_32 (abfd, (bfd_vma) src -> exitProcedureOffset,
143 (bfd_byte *) dst -> exitProcedureOffset);
144 bfd_h_put_32 (abfd, (bfd_vma) src -> checkUnloadProcedureOffset,
145 (bfd_byte *) dst -> checkUnloadProcedureOffset);
146 bfd_h_put_32 (abfd, (bfd_vma) src -> moduleType,
147 (bfd_byte *) dst -> moduleType);
148 bfd_h_put_32 (abfd, (bfd_vma) src -> flags,
149 (bfd_byte *) dst -> flags);
150 }
This page took 0.034635 seconds and 5 git commands to generate.