hc
2023-02-13 e440ec23c5a540cdd3f7464e8779219be6fd3d95
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This file documents the BFD library.
 
Copyright (C) 1991-2016 Free Software Foundation, Inc.
 
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with the
Invariant Sections being "GNU General Public License" and "Funding
Free Software", the Front-Cover texts being (a) (see below), and with
the Back-Cover Texts being (b) (see below).  A copy of the license is
included in the section entitled "GNU Free Documentation License".
 
(a) The FSF's Front-Cover Text is:
 
A GNU Manual
 
(b) The FSF's Back-Cover Text is:
 
You have freedom to copy and modify this GNU Manual, like GNU
     software.  Copies published by the Free Software Foundation raise
     funds for GNU development. -->
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>Untitled Document: Internal</title>
 
<meta name="description" content="Untitled Document: Internal">
<meta name="keywords" content="Untitled Document: Internal">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="BFD-Index.html#BFD-Index" rel="index" title="BFD Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="BFD-front-end.html#BFD-front-end" rel="up" title="BFD front end">
<link href="File-Caching.html#File-Caching" rel="next" title="File Caching">
<link href="Opening-and-Closing.html#Opening-and-Closing" rel="prev" title="Opening and Closing">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
 
 
</head>
 
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Internal"></a>
<div class="header">
<p>
Next: <a href="File-Caching.html#File-Caching" accesskey="n" rel="next">File Caching</a>, Previous: <a href="Opening-and-Closing.html#Opening-and-Closing" accesskey="p" rel="prev">Opening and Closing</a>, Up: <a href="BFD-front-end.html#BFD-front-end" accesskey="u" rel="up">BFD front end</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="BFD-Index.html#BFD-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Implementation-details"></a>
<h3 class="section">2.15 Implementation details</h3>
 
 
<a name="Internal-functions"></a>
<h4 class="subsection">2.15.1 Internal functions</h4>
 
 
<p><strong>Description</strong><br>
These routines are used within BFD.
They are not intended for export, but are documented here for
completeness.
</p>
<a name="index-bfd_005fwrite_005fbigendian_005f4byte_005fint"></a>
<a name="bfd_005fwrite_005fbigendian_005f4byte_005fint"></a>
<h4 class="subsubsection">2.15.1.1 <code>bfd_write_bigendian_4byte_int</code></h4>
<p><strong>Synopsis</strong>
</p><div class="example">
<pre class="example">bfd_boolean bfd_write_bigendian_4byte_int (bfd *, unsigned int);
</pre></div>
<p><strong>Description</strong><br>
Write a 4 byte integer <var>i</var> to the output BFD <var>abfd</var>, in big
endian order regardless of what else is going on.  This is useful in
archives.
</p>
<a name="index-bfd_005fput_005fsize"></a>
<a name="bfd_005fput_005fsize"></a>
<h4 class="subsubsection">2.15.1.2 <code>bfd_put_size</code></h4>
<a name="index-bfd_005fget_005fsize-1"></a>
<a name="bfd_005fget_005fsize-1"></a>
<h4 class="subsubsection">2.15.1.3 <code>bfd_get_size</code></h4>
<p><strong>Description</strong><br>
These macros as used for reading and writing raw data in
sections; each access (except for bytes) is vectored through
the target format of the BFD and mangled accordingly. The
mangling performs any necessary endian translations and
removes alignment restrictions.  Note that types accepted and
returned by these macros are identical so they can be swapped
around in macros&mdash;for example, <samp>libaout.h</samp> defines <code>GET_WORD</code>
to either <code>bfd_get_32</code> or <code>bfd_get_64</code>.
</p>
<p>In the put routines, <var>val</var> must be a <code>bfd_vma</code>.  If we are on a
system without prototypes, the caller is responsible for making
sure that is true, with a cast if necessary.  We don&rsquo;t cast
them in the macro definitions because that would prevent <code>lint</code>
or <code>gcc -Wall</code> from detecting sins such as passing a pointer.
To detect calling these with less than a <code>bfd_vma</code>, use
<code>gcc -Wconversion</code> on a host with 64 bit <code>bfd_vma</code>&rsquo;s.
</p><div class="example">
<pre class="example">
/* Byte swapping macros for user section data.  */
 
#define bfd_put_8(abfd, val, ptr) \
  ((void) (*((unsigned char *) (ptr)) = (val) &amp; 0xff))
#define bfd_put_signed_8 \
  bfd_put_8
#define bfd_get_8(abfd, ptr) \
  (*(const unsigned char *) (ptr) &amp; 0xff)
#define bfd_get_signed_8(abfd, ptr) \
  (((*(const unsigned char *) (ptr) &amp; 0xff) ^ 0x80) - 0x80)
 
#define bfd_put_16(abfd, val, ptr) \
  BFD_SEND (abfd, bfd_putx16, ((val),(ptr)))
#define bfd_put_signed_16 \
  bfd_put_16
#define bfd_get_16(abfd, ptr) \
  BFD_SEND (abfd, bfd_getx16, (ptr))
#define bfd_get_signed_16(abfd, ptr) \
  BFD_SEND (abfd, bfd_getx_signed_16, (ptr))
 
#define bfd_put_32(abfd, val, ptr) \
  BFD_SEND (abfd, bfd_putx32, ((val),(ptr)))
#define bfd_put_signed_32 \
  bfd_put_32
#define bfd_get_32(abfd, ptr) \
  BFD_SEND (abfd, bfd_getx32, (ptr))
#define bfd_get_signed_32(abfd, ptr) \
  BFD_SEND (abfd, bfd_getx_signed_32, (ptr))
 
#define bfd_put_64(abfd, val, ptr) \
  BFD_SEND (abfd, bfd_putx64, ((val), (ptr)))
#define bfd_put_signed_64 \
  bfd_put_64
#define bfd_get_64(abfd, ptr) \
  BFD_SEND (abfd, bfd_getx64, (ptr))
#define bfd_get_signed_64(abfd, ptr) \
  BFD_SEND (abfd, bfd_getx_signed_64, (ptr))
 
#define bfd_get(bits, abfd, ptr)                       \
  ((bits) == 8 ? (bfd_vma) bfd_get_8 (abfd, ptr)       \
   : (bits) == 16 ? bfd_get_16 (abfd, ptr)             \
   : (bits) == 32 ? bfd_get_32 (abfd, ptr)             \
   : (bits) == 64 ? bfd_get_64 (abfd, ptr)             \
   : (abort (), (bfd_vma) - 1))
 
#define bfd_put(bits, abfd, val, ptr)                  \
  ((bits) == 8 ? bfd_put_8  (abfd, val, ptr)           \
   : (bits) == 16 ? bfd_put_16 (abfd, val, ptr)                \
   : (bits) == 32 ? bfd_put_32 (abfd, val, ptr)                \
   : (bits) == 64 ? bfd_put_64 (abfd, val, ptr)                \
   : (abort (), (void) 0))
 
</pre></div>
 
<a name="index-bfd_005fh_005fput_005fsize"></a>
<a name="bfd_005fh_005fput_005fsize"></a>
<h4 class="subsubsection">2.15.1.4 <code>bfd_h_put_size</code></h4>
<p><strong>Description</strong><br>
These macros have the same function as their <code>bfd_get_x</code>
brethren, except that they are used for removing information
for the header records of object files. Believe it or not,
some object files keep their header records in big endian
order and their data in little endian order.
</p><div class="example">
<pre class="example">
/* Byte swapping macros for file header data.  */
 
#define bfd_h_put_8(abfd, val, ptr) \
  bfd_put_8 (abfd, val, ptr)
#define bfd_h_put_signed_8(abfd, val, ptr) \
  bfd_put_8 (abfd, val, ptr)
#define bfd_h_get_8(abfd, ptr) \
  bfd_get_8 (abfd, ptr)
#define bfd_h_get_signed_8(abfd, ptr) \
  bfd_get_signed_8 (abfd, ptr)
 
#define bfd_h_put_16(abfd, val, ptr) \
  BFD_SEND (abfd, bfd_h_putx16, (val, ptr))
#define bfd_h_put_signed_16 \
  bfd_h_put_16
#define bfd_h_get_16(abfd, ptr) \
  BFD_SEND (abfd, bfd_h_getx16, (ptr))
#define bfd_h_get_signed_16(abfd, ptr) \
  BFD_SEND (abfd, bfd_h_getx_signed_16, (ptr))
 
#define bfd_h_put_32(abfd, val, ptr) \
  BFD_SEND (abfd, bfd_h_putx32, (val, ptr))
#define bfd_h_put_signed_32 \
  bfd_h_put_32
#define bfd_h_get_32(abfd, ptr) \
  BFD_SEND (abfd, bfd_h_getx32, (ptr))
#define bfd_h_get_signed_32(abfd, ptr) \
  BFD_SEND (abfd, bfd_h_getx_signed_32, (ptr))
 
#define bfd_h_put_64(abfd, val, ptr) \
  BFD_SEND (abfd, bfd_h_putx64, (val, ptr))
#define bfd_h_put_signed_64 \
  bfd_h_put_64
#define bfd_h_get_64(abfd, ptr) \
  BFD_SEND (abfd, bfd_h_getx64, (ptr))
#define bfd_h_get_signed_64(abfd, ptr) \
  BFD_SEND (abfd, bfd_h_getx_signed_64, (ptr))
 
/* Aliases for the above, which should eventually go away.  */
 
#define H_PUT_64  bfd_h_put_64
#define H_PUT_32  bfd_h_put_32
#define H_PUT_16  bfd_h_put_16
#define H_PUT_8   bfd_h_put_8
#define H_PUT_S64 bfd_h_put_signed_64
#define H_PUT_S32 bfd_h_put_signed_32
#define H_PUT_S16 bfd_h_put_signed_16
#define H_PUT_S8  bfd_h_put_signed_8
#define H_GET_64  bfd_h_get_64
#define H_GET_32  bfd_h_get_32
#define H_GET_16  bfd_h_get_16
#define H_GET_8   bfd_h_get_8
#define H_GET_S64 bfd_h_get_signed_64
#define H_GET_S32 bfd_h_get_signed_32
#define H_GET_S16 bfd_h_get_signed_16
#define H_GET_S8  bfd_h_get_signed_8
 
 
</pre></div>
 
<a name="index-bfd_005flog2"></a>
<a name="bfd_005flog2"></a>
<h4 class="subsubsection">2.15.1.5 <code>bfd_log2</code></h4>
<p><strong>Synopsis</strong>
</p><div class="example">
<pre class="example">unsigned int bfd_log2 (bfd_vma x);
</pre></div>
<p><strong>Description</strong><br>
Return the log base 2 of the value supplied, rounded up.  E.g., an
<var>x</var> of 1025 returns 11.  A <var>x</var> of 0 returns 0.
</p>
 
<hr>
<div class="header">
<p>
Next: <a href="File-Caching.html#File-Caching" accesskey="n" rel="next">File Caching</a>, Previous: <a href="Opening-and-Closing.html#Opening-and-Closing" accesskey="p" rel="prev">Opening and Closing</a>, Up: <a href="BFD-front-end.html#BFD-front-end" accesskey="u" rel="up">BFD front end</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="BFD-Index.html#BFD-Index" title="Index" rel="index">Index</a>]</p>
</div>
 
 
 
</body>
</html>