OpenCores
URL https://opencores.org/ocsvn/open8_urisc/open8_urisc/trunk

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [bfd/] [nlmswap.h] - Blame information for rev 14

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 14 khays
/* NLM (NetWare Loadable Module) swapping routines for BFD.
2
   Copyright 1993, 2000, 2001, 2005, 2007 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 3 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., 51 Franklin Street - Fifth Floor, Boston,
22
   MA 02110-1301, USA.  */
23
 
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
 
34
/* Translate an NLM fixed length file header in external format into an NLM
35
   file header in internal format.  */
36
 
37
static void
38
nlm_swap_fixed_header_in (bfd *abfd,
39
                          void * realsrc,
40
                          Nlm_Internal_Fixed_Header *dst)
41
{
42
  Nlm_External_Fixed_Header *src = (Nlm_External_Fixed_Header *) realsrc;
43
 
44
  memcpy (dst->signature, src->signature, NLM_SIGNATURE_SIZE);
45
  memcpy (dst->moduleName, src->moduleName, NLM_MODULE_NAME_SIZE);
46
  dst->version =
47
    H_GET_32 (abfd, src->version);
48
  dst->codeImageOffset =
49
    H_GET_32 (abfd, src->codeImageOffset);
50
  dst->codeImageSize =
51
    H_GET_32 (abfd, src->codeImageSize);
52
  dst->dataImageOffset =
53
    H_GET_32 (abfd, src->dataImageOffset);
54
  dst->dataImageSize =
55
    H_GET_32 (abfd, src->dataImageSize);
56
  dst->uninitializedDataSize =
57
    H_GET_32 (abfd, src->uninitializedDataSize);
58
  dst->customDataOffset =
59
    H_GET_32 (abfd, src->customDataOffset);
60
  dst->customDataSize =
61
    H_GET_32 (abfd, src->customDataSize);
62
  dst->moduleDependencyOffset =
63
    H_GET_32 (abfd, src->moduleDependencyOffset);
64
  dst->numberOfModuleDependencies =
65
    H_GET_32 (abfd, src->numberOfModuleDependencies);
66
  dst->relocationFixupOffset =
67
    H_GET_32 (abfd, src->relocationFixupOffset);
68
  dst->numberOfRelocationFixups =
69
    H_GET_32 (abfd, src->numberOfRelocationFixups);
70
  dst->externalReferencesOffset =
71
    H_GET_32 (abfd, src->externalReferencesOffset);
72
  dst->numberOfExternalReferences =
73
    H_GET_32 (abfd, src->numberOfExternalReferences);
74
  dst->publicsOffset =
75
    H_GET_32 (abfd, src->publicsOffset);
76
  dst->numberOfPublics =
77
    H_GET_32 (abfd, src->numberOfPublics);
78
  dst->debugInfoOffset =
79
    H_GET_32 (abfd, src->debugInfoOffset);
80
  dst->numberOfDebugRecords =
81
    H_GET_32 (abfd, src->numberOfDebugRecords);
82
  dst->codeStartOffset =
83
    H_GET_32 (abfd, src->codeStartOffset);
84
  dst->exitProcedureOffset =
85
    H_GET_32 (abfd, src->exitProcedureOffset);
86
  dst->checkUnloadProcedureOffset =
87
    H_GET_32 (abfd, src->checkUnloadProcedureOffset);
88
  dst->moduleType =
89
    H_GET_32 (abfd, src->moduleType);
90
  dst->flags =
91
    H_GET_32 (abfd, src->flags);
92
}
93
 
94
/* Translate an NLM fixed length file header in internal format into
95
   an NLM file header in external format.  */
96
 
97
static void
98
nlm_swap_fixed_header_out (bfd *abfd,
99
                           Nlm_Internal_Fixed_Header *src,
100
                           void * realdst)
101
{
102
  Nlm_External_Fixed_Header *dst = (Nlm_External_Fixed_Header *) realdst;
103
 
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);
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);
153
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.