Debian Codegraph @

gnu/binutils-2.35.1/bfd/doc/libbfd.texi

raw
1 @section Implementation details
2
3
4 @subsection Internal functions
5
6
7 @strong{Description}@*
8 These routines are used within BFD.
9 They are not intended for export, but are documented here for
10 completeness.
11
12 @findex bfd_write_bigendian_4byte_int
13 @subsubsection @code{bfd_write_bigendian_4byte_int}
14 @strong{Synopsis}
15 @example
16 bfd_boolean bfd_write_bigendian_4byte_int (bfd *, unsigned int);
17 @end example
18 @strong{Description}@*
19 Write a 4 byte integer @var{i} to the output BFD @var{abfd}, in big
20 endian order regardless of what else is going on. This is useful in
21 archives.
22
23 @findex bfd_put_size
24 @subsubsection @code{bfd_put_size}
25 @findex bfd_get_size
26 @subsubsection @code{bfd_get_size}
27 @strong{Description}@*
28 These macros as used for reading and writing raw data in
29 sections; each access (except for bytes) is vectored through
30 the target format of the BFD and mangled accordingly. The
31 mangling performs any necessary endian translations and
32 removes alignment restrictions. Note that types accepted and
33 returned by these macros are identical so they can be swapped
34 around in macros---for example, @file{libaout.h} defines @code{GET_WORD}
35 to either @code{bfd_get_32} or @code{bfd_get_64}.
36
37 In the put routines, @var{val} must be a @code{bfd_vma}. If we are on a
38 system without prototypes, the caller is responsible for making
39 sure that is true, with a cast if necessary. We don't cast
40 them in the macro definitions because that would prevent @code{lint}
41 or @code{gcc -Wall} from detecting sins such as passing a pointer.
42 To detect calling these with less than a @code{bfd_vma}, use
43 @code{gcc -Wconversion} on a host with 64 bit @code{bfd_vma}'s.
44 @example
45
46 /* Byte swapping macros for user section data. */
47
48 #define bfd_put_8(abfd, val, ptr) \
49 ((void) (*((unsigned char *) (ptr)) = (val) & 0xff))
50 #define bfd_put_signed_8 \
51 bfd_put_8
52 #define bfd_get_8(abfd, ptr) \
53 ((bfd_vma) *(const unsigned char *) (ptr) & 0xff)
54 #define bfd_get_signed_8(abfd, ptr) \
55 ((((bfd_signed_vma) *(const unsigned char *) (ptr) & 0xff) ^ 0x80) - 0x80)
56
57 #define bfd_put_16(abfd, val, ptr) \
58 BFD_SEND (abfd, bfd_putx16, ((val),(ptr)))
59 #define bfd_put_signed_16 \
60 bfd_put_16
61 #define bfd_get_16(abfd, ptr) \
62 BFD_SEND (abfd, bfd_getx16, (ptr))
63 #define bfd_get_signed_16(abfd, ptr) \
64 BFD_SEND (abfd, bfd_getx_signed_16, (ptr))
65
66 #define bfd_put_24(abfd, val, ptr) \
67 do \
68 if (bfd_big_endian (abfd)) \
69 bfd_putb24 ((val), (ptr)); \
70 else \
71 bfd_putl24 ((val), (ptr)); \
72 while (0)
73
74 bfd_vma bfd_getb24 (const void *p);
75 bfd_vma bfd_getl24 (const void *p);
76
77 #define bfd_get_24(abfd, ptr) \
78 (bfd_big_endian (abfd) ? bfd_getb24 (ptr) : bfd_getl24 (ptr))
79
80 #define bfd_put_32(abfd, val, ptr) \
81 BFD_SEND (abfd, bfd_putx32, ((val),(ptr)))
82 #define bfd_put_signed_32 \
83 bfd_put_32
84 #define bfd_get_32(abfd, ptr) \
85 BFD_SEND (abfd, bfd_getx32, (ptr))
86 #define bfd_get_signed_32(abfd, ptr) \
87 BFD_SEND (abfd, bfd_getx_signed_32, (ptr))
88
89 #define bfd_put_64(abfd, val, ptr) \
90 BFD_SEND (abfd, bfd_putx64, ((val), (ptr)))
91 #define bfd_put_signed_64 \
92 bfd_put_64
93 #define bfd_get_64(abfd, ptr) \
94 BFD_SEND (abfd, bfd_getx64, (ptr))
95 #define bfd_get_signed_64(abfd, ptr) \
96 BFD_SEND (abfd, bfd_getx_signed_64, (ptr))
97
98 #define bfd_get(bits, abfd, ptr) \
99 ((bits) == 8 ? bfd_get_8 (abfd, ptr) \
100 : (bits) == 16 ? bfd_get_16 (abfd, ptr) \
101 : (bits) == 32 ? bfd_get_32 (abfd, ptr) \
102 : (bits) == 64 ? bfd_get_64 (abfd, ptr) \
103 : (abort (), (bfd_vma) - 1))
104
105 #define bfd_put(bits, abfd, val, ptr) \
106 ((bits) == 8 ? bfd_put_8 (abfd, val, ptr) \
107 : (bits) == 16 ? bfd_put_16 (abfd, val, ptr) \
108 : (bits) == 32 ? bfd_put_32 (abfd, val, ptr) \
109 : (bits) == 64 ? bfd_put_64 (abfd, val, ptr) \
110 : (abort (), (void) 0))
111
112 @end example
113
114 @findex bfd_h_put_size
115 @subsubsection @code{bfd_h_put_size}
116 @strong{Description}@*
117 These macros have the same function as their @code{bfd_get_x}
118 brethren, except that they are used for removing information
119 for the header records of object files. Believe it or not,
120 some object files keep their header records in big endian
121 order and their data in little endian order.
122 @example
123
124 /* Byte swapping macros for file header data. */
125
126 #define bfd_h_put_8(abfd, val, ptr) \
127 bfd_put_8 (abfd, val, ptr)
128 #define bfd_h_put_signed_8(abfd, val, ptr) \
129 bfd_put_8 (abfd, val, ptr)
130 #define bfd_h_get_8(abfd, ptr) \
131 bfd_get_8 (abfd, ptr)
132 #define bfd_h_get_signed_8(abfd, ptr) \
133 bfd_get_signed_8 (abfd, ptr)
134
135 #define bfd_h_put_16(abfd, val, ptr) \
136 BFD_SEND (abfd, bfd_h_putx16, (val, ptr))
137 #define bfd_h_put_signed_16 \
138 bfd_h_put_16
139 #define bfd_h_get_16(abfd, ptr) \
140 BFD_SEND (abfd, bfd_h_getx16, (ptr))
141 #define bfd_h_get_signed_16(abfd, ptr) \
142 BFD_SEND (abfd, bfd_h_getx_signed_16, (ptr))
143
144 #define bfd_h_put_32(abfd, val, ptr) \
145 BFD_SEND (abfd, bfd_h_putx32, (val, ptr))
146 #define bfd_h_put_signed_32 \
147 bfd_h_put_32
148 #define bfd_h_get_32(abfd, ptr) \
149 BFD_SEND (abfd, bfd_h_getx32, (ptr))
150 #define bfd_h_get_signed_32(abfd, ptr) \
151 BFD_SEND (abfd, bfd_h_getx_signed_32, (ptr))
152
153 #define bfd_h_put_64(abfd, val, ptr) \
154 BFD_SEND (abfd, bfd_h_putx64, (val, ptr))
155 #define bfd_h_put_signed_64 \
156 bfd_h_put_64
157 #define bfd_h_get_64(abfd, ptr) \
158 BFD_SEND (abfd, bfd_h_getx64, (ptr))
159 #define bfd_h_get_signed_64(abfd, ptr) \
160 BFD_SEND (abfd, bfd_h_getx_signed_64, (ptr))
161
162 /* Aliases for the above, which should eventually go away. */
163
164 #define H_PUT_64 bfd_h_put_64
165 #define H_PUT_32 bfd_h_put_32
166 #define H_PUT_16 bfd_h_put_16
167 #define H_PUT_8 bfd_h_put_8
168 #define H_PUT_S64 bfd_h_put_signed_64
169 #define H_PUT_S32 bfd_h_put_signed_32
170 #define H_PUT_S16 bfd_h_put_signed_16
171 #define H_PUT_S8 bfd_h_put_signed_8
172 #define H_GET_64 bfd_h_get_64
173 #define H_GET_32 bfd_h_get_32
174 #define H_GET_16 bfd_h_get_16
175 #define H_GET_8 bfd_h_get_8
176 #define H_GET_S64 bfd_h_get_signed_64
177 #define H_GET_S32 bfd_h_get_signed_32
178 #define H_GET_S16 bfd_h_get_signed_16
179 #define H_GET_S8 bfd_h_get_signed_8
180
181
182 @end example
183
184 @findex bfd_log2
185 @subsubsection @code{bfd_log2}
186 @strong{Synopsis}
187 @example
188 unsigned int bfd_log2 (bfd_vma x);
189 @end example
190 @strong{Description}@*
191 Return the log base 2 of the value supplied, rounded up. E.g., an
192 @var{x} of 1025 returns 11. A @var{x} of 0 returns 0.
193