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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [bfd/] [nlmswap.h] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 104 markom
/* 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., 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
    bfd_h_get_32 (abfd, (bfd_byte *) src->version);
52
  dst->codeImageOffset =
53
    bfd_h_get_32 (abfd, (bfd_byte *) src->codeImageOffset);
54
  dst->codeImageSize =
55
    bfd_h_get_32 (abfd, (bfd_byte *) src->codeImageSize);
56
  dst->dataImageOffset =
57
    bfd_h_get_32 (abfd, (bfd_byte *) src->dataImageOffset);
58
  dst->dataImageSize =
59
    bfd_h_get_32 (abfd, (bfd_byte *) src->dataImageSize);
60
  dst->uninitializedDataSize =
61
    bfd_h_get_32 (abfd, (bfd_byte *) src->uninitializedDataSize);
62
  dst->customDataOffset =
63
    bfd_h_get_32 (abfd, (bfd_byte *) src->customDataOffset);
64
  dst->customDataSize =
65
    bfd_h_get_32 (abfd, (bfd_byte *) src->customDataSize);
66
  dst->moduleDependencyOffset =
67
    bfd_h_get_32 (abfd, (bfd_byte *) src->moduleDependencyOffset);
68
  dst->numberOfModuleDependencies =
69
    bfd_h_get_32 (abfd, (bfd_byte *) src->numberOfModuleDependencies);
70
  dst->relocationFixupOffset =
71
    bfd_h_get_32 (abfd, (bfd_byte *) src->relocationFixupOffset);
72
  dst->numberOfRelocationFixups =
73
    bfd_h_get_32 (abfd, (bfd_byte *) src->numberOfRelocationFixups);
74
  dst->externalReferencesOffset =
75
    bfd_h_get_32 (abfd, (bfd_byte *) src->externalReferencesOffset);
76
  dst->numberOfExternalReferences =
77
    bfd_h_get_32 (abfd, (bfd_byte *) src->numberOfExternalReferences);
78
  dst->publicsOffset =
79
    bfd_h_get_32 (abfd, (bfd_byte *) src->publicsOffset);
80
  dst->numberOfPublics =
81
    bfd_h_get_32 (abfd, (bfd_byte *) src->numberOfPublics);
82
  dst->debugInfoOffset =
83
    bfd_h_get_32 (abfd, (bfd_byte *) src->debugInfoOffset);
84
  dst->numberOfDebugRecords =
85
    bfd_h_get_32 (abfd, (bfd_byte *) src->numberOfDebugRecords);
86
  dst->codeStartOffset =
87
    bfd_h_get_32 (abfd, (bfd_byte *) src->codeStartOffset);
88
  dst->exitProcedureOffset =
89
    bfd_h_get_32 (abfd, (bfd_byte *) src->exitProcedureOffset);
90
  dst->checkUnloadProcedureOffset =
91
    bfd_h_get_32 (abfd, (bfd_byte *) src->checkUnloadProcedureOffset);
92
  dst->moduleType =
93
    bfd_h_get_32 (abfd, (bfd_byte *) src->moduleType);
94
  dst->flags =
95
    bfd_h_get_32 (abfd, (bfd_byte *) 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
  bfd_h_put_32 (abfd, (bfd_vma) src->version,
112
                (bfd_byte *) dst->version);
113
  bfd_h_put_32 (abfd, (bfd_vma) src->codeImageOffset,
114
                (bfd_byte *) dst->codeImageOffset);
115
  bfd_h_put_32 (abfd, (bfd_vma) src->codeImageSize,
116
                (bfd_byte *) dst->codeImageSize);
117
  bfd_h_put_32 (abfd, (bfd_vma) src->dataImageOffset,
118
                (bfd_byte *) dst->dataImageOffset);
119
  bfd_h_put_32 (abfd, (bfd_vma) src->dataImageSize,
120
                (bfd_byte *) dst->dataImageSize);
121
  bfd_h_put_32 (abfd, (bfd_vma) src->uninitializedDataSize,
122
                (bfd_byte *) dst->uninitializedDataSize);
123
  bfd_h_put_32 (abfd, (bfd_vma) src->customDataOffset,
124
                (bfd_byte *) dst->customDataOffset);
125
  bfd_h_put_32 (abfd, (bfd_vma) src->customDataSize,
126
                (bfd_byte *) dst->customDataSize);
127
  bfd_h_put_32 (abfd, (bfd_vma) src->moduleDependencyOffset,
128
                (bfd_byte *) dst->moduleDependencyOffset);
129
  bfd_h_put_32 (abfd, (bfd_vma) src->numberOfModuleDependencies,
130
                (bfd_byte *) dst->numberOfModuleDependencies);
131
  bfd_h_put_32 (abfd, (bfd_vma) src->relocationFixupOffset,
132
                (bfd_byte *) dst->relocationFixupOffset);
133
  bfd_h_put_32 (abfd, (bfd_vma) src->numberOfRelocationFixups,
134
                (bfd_byte *) dst->numberOfRelocationFixups);
135
  bfd_h_put_32 (abfd, (bfd_vma) src->externalReferencesOffset,
136
                (bfd_byte *) dst->externalReferencesOffset);
137
  bfd_h_put_32 (abfd, (bfd_vma) src->numberOfExternalReferences,
138
                (bfd_byte *) dst->numberOfExternalReferences);
139
  bfd_h_put_32 (abfd, (bfd_vma) src->publicsOffset,
140
                (bfd_byte *) dst->publicsOffset);
141
  bfd_h_put_32 (abfd, (bfd_vma) src->numberOfPublics,
142
                (bfd_byte *) dst->numberOfPublics);
143
  bfd_h_put_32 (abfd, (bfd_vma) src->debugInfoOffset,
144
                (bfd_byte *) dst->debugInfoOffset);
145
  bfd_h_put_32 (abfd, (bfd_vma) src->numberOfDebugRecords,
146
                (bfd_byte *) dst->numberOfDebugRecords);
147
  bfd_h_put_32 (abfd, (bfd_vma) src->codeStartOffset,
148
                (bfd_byte *) dst->codeStartOffset);
149
  bfd_h_put_32 (abfd, (bfd_vma) src->exitProcedureOffset,
150
                (bfd_byte *) dst->exitProcedureOffset);
151
  bfd_h_put_32 (abfd, (bfd_vma) src->checkUnloadProcedureOffset,
152
                (bfd_byte *) dst->checkUnloadProcedureOffset);
153
  bfd_h_put_32 (abfd, (bfd_vma) src->moduleType,
154
                (bfd_byte *) dst->moduleType);
155
  bfd_h_put_32 (abfd, (bfd_vma) src->flags,
156
                (bfd_byte *) dst->flags);
157
}

powered by: WebSVN 2.1.0

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