| 1 | /* Assorted BFD support routines, only used internally.
|
|---|
| 2 | Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
|---|
| 3 | 2000, 2001, 2002
|
|---|
| 4 | Free Software Foundation, Inc.
|
|---|
| 5 | Written by Cygnus Support.
|
|---|
| 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 | #include "bfd.h"
|
|---|
| 24 | #include "sysdep.h"
|
|---|
| 25 | #include "libbfd.h"
|
|---|
| 26 |
|
|---|
| 27 | #ifndef HAVE_GETPAGESIZE
|
|---|
| 28 | #define getpagesize() 2048
|
|---|
| 29 | #endif
|
|---|
| 30 |
|
|---|
| 31 | /*
|
|---|
| 32 | SECTION
|
|---|
| 33 | Internal functions
|
|---|
| 34 |
|
|---|
| 35 | DESCRIPTION
|
|---|
| 36 | These routines are used within BFD.
|
|---|
| 37 | They are not intended for export, but are documented here for
|
|---|
| 38 | completeness.
|
|---|
| 39 | */
|
|---|
| 40 |
|
|---|
| 41 | /* A routine which is used in target vectors for unsupported
|
|---|
| 42 | operations. */
|
|---|
| 43 |
|
|---|
| 44 | bfd_boolean
|
|---|
| 45 | bfd_false (ignore)
|
|---|
| 46 | bfd *ignore ATTRIBUTE_UNUSED;
|
|---|
| 47 | {
|
|---|
| 48 | bfd_set_error (bfd_error_invalid_operation);
|
|---|
| 49 | return FALSE;
|
|---|
| 50 | }
|
|---|
| 51 |
|
|---|
| 52 | /* A routine which is used in target vectors for supported operations
|
|---|
| 53 | which do not actually do anything. */
|
|---|
| 54 |
|
|---|
| 55 | bfd_boolean
|
|---|
| 56 | bfd_true (ignore)
|
|---|
| 57 | bfd *ignore ATTRIBUTE_UNUSED;
|
|---|
| 58 | {
|
|---|
| 59 | return TRUE;
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | /* A routine which is used in target vectors for unsupported
|
|---|
| 63 | operations which return a pointer value. */
|
|---|
| 64 |
|
|---|
| 65 | PTR
|
|---|
| 66 | bfd_nullvoidptr (ignore)
|
|---|
| 67 | bfd *ignore ATTRIBUTE_UNUSED;
|
|---|
| 68 | {
|
|---|
| 69 | bfd_set_error (bfd_error_invalid_operation);
|
|---|
| 70 | return NULL;
|
|---|
| 71 | }
|
|---|
| 72 |
|
|---|
| 73 | int
|
|---|
| 74 | bfd_0 (ignore)
|
|---|
| 75 | bfd *ignore ATTRIBUTE_UNUSED;
|
|---|
| 76 | {
|
|---|
| 77 | return 0;
|
|---|
| 78 | }
|
|---|
| 79 |
|
|---|
| 80 | unsigned int
|
|---|
| 81 | bfd_0u (ignore)
|
|---|
| 82 | bfd *ignore ATTRIBUTE_UNUSED;
|
|---|
| 83 | {
|
|---|
| 84 | return 0;
|
|---|
| 85 | }
|
|---|
| 86 |
|
|---|
| 87 | long
|
|---|
| 88 | bfd_0l (ignore)
|
|---|
| 89 | bfd *ignore ATTRIBUTE_UNUSED;
|
|---|
| 90 | {
|
|---|
| 91 | return 0;
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| 94 | /* A routine which is used in target vectors for unsupported
|
|---|
| 95 | operations which return -1 on error. */
|
|---|
| 96 |
|
|---|
| 97 | long
|
|---|
| 98 | _bfd_n1 (ignore_abfd)
|
|---|
| 99 | bfd *ignore_abfd ATTRIBUTE_UNUSED;
|
|---|
| 100 | {
|
|---|
| 101 | bfd_set_error (bfd_error_invalid_operation);
|
|---|
| 102 | return -1;
|
|---|
| 103 | }
|
|---|
| 104 |
|
|---|
| 105 | void
|
|---|
| 106 | bfd_void (ignore)
|
|---|
| 107 | bfd *ignore ATTRIBUTE_UNUSED;
|
|---|
| 108 | {
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 | bfd_boolean
|
|---|
| 112 | _bfd_nocore_core_file_matches_executable_p (ignore_core_bfd, ignore_exec_bfd)
|
|---|
| 113 | bfd *ignore_core_bfd ATTRIBUTE_UNUSED;
|
|---|
| 114 | bfd *ignore_exec_bfd ATTRIBUTE_UNUSED;
|
|---|
| 115 | {
|
|---|
| 116 | bfd_set_error (bfd_error_invalid_operation);
|
|---|
| 117 | return FALSE;
|
|---|
| 118 | }
|
|---|
| 119 |
|
|---|
| 120 | /* Routine to handle core_file_failing_command entry point for targets
|
|---|
| 121 | without core file support. */
|
|---|
| 122 |
|
|---|
| 123 | char *
|
|---|
| 124 | _bfd_nocore_core_file_failing_command (ignore_abfd)
|
|---|
| 125 | bfd *ignore_abfd ATTRIBUTE_UNUSED;
|
|---|
| 126 | {
|
|---|
| 127 | bfd_set_error (bfd_error_invalid_operation);
|
|---|
| 128 | return (char *)NULL;
|
|---|
| 129 | }
|
|---|
| 130 |
|
|---|
| 131 | /* Routine to handle core_file_failing_signal entry point for targets
|
|---|
| 132 | without core file support. */
|
|---|
| 133 |
|
|---|
| 134 | int
|
|---|
| 135 | _bfd_nocore_core_file_failing_signal (ignore_abfd)
|
|---|
| 136 | bfd *ignore_abfd ATTRIBUTE_UNUSED;
|
|---|
| 137 | {
|
|---|
| 138 | bfd_set_error (bfd_error_invalid_operation);
|
|---|
| 139 | return 0;
|
|---|
| 140 | }
|
|---|
| 141 |
|
|---|
| 142 | const bfd_target *
|
|---|
| 143 | _bfd_dummy_target (ignore_abfd)
|
|---|
| 144 | bfd *ignore_abfd ATTRIBUTE_UNUSED;
|
|---|
| 145 | {
|
|---|
| 146 | bfd_set_error (bfd_error_wrong_format);
|
|---|
| 147 | return 0;
|
|---|
| 148 | }
|
|---|
| 149 | |
|---|
| 150 |
|
|---|
| 151 | /* Allocate memory using malloc. */
|
|---|
| 152 |
|
|---|
| 153 | PTR
|
|---|
| 154 | bfd_malloc (size)
|
|---|
| 155 | bfd_size_type size;
|
|---|
| 156 | {
|
|---|
| 157 | PTR ptr;
|
|---|
| 158 |
|
|---|
| 159 | if (size != (size_t) size)
|
|---|
| 160 | {
|
|---|
| 161 | bfd_set_error (bfd_error_no_memory);
|
|---|
| 162 | return NULL;
|
|---|
| 163 | }
|
|---|
| 164 |
|
|---|
| 165 | ptr = (PTR) malloc ((size_t) size);
|
|---|
| 166 | if (ptr == NULL && (size_t) size != 0)
|
|---|
| 167 | bfd_set_error (bfd_error_no_memory);
|
|---|
| 168 |
|
|---|
| 169 | return ptr;
|
|---|
| 170 | }
|
|---|
| 171 |
|
|---|
| 172 | /* Reallocate memory using realloc. */
|
|---|
| 173 |
|
|---|
| 174 | PTR
|
|---|
| 175 | bfd_realloc (ptr, size)
|
|---|
| 176 | PTR ptr;
|
|---|
| 177 | bfd_size_type size;
|
|---|
| 178 | {
|
|---|
| 179 | PTR ret;
|
|---|
| 180 |
|
|---|
| 181 | if (size != (size_t) size)
|
|---|
| 182 | {
|
|---|
| 183 | bfd_set_error (bfd_error_no_memory);
|
|---|
| 184 | return NULL;
|
|---|
| 185 | }
|
|---|
| 186 |
|
|---|
| 187 | if (ptr == NULL)
|
|---|
| 188 | ret = (PTR) malloc ((size_t) size);
|
|---|
| 189 | else
|
|---|
| 190 | ret = (PTR) realloc (ptr, (size_t) size);
|
|---|
| 191 |
|
|---|
| 192 | if (ret == NULL && (size_t) size != 0)
|
|---|
| 193 | bfd_set_error (bfd_error_no_memory);
|
|---|
| 194 |
|
|---|
| 195 | return ret;
|
|---|
| 196 | }
|
|---|
| 197 |
|
|---|
| 198 | /* Allocate memory using malloc and clear it. */
|
|---|
| 199 |
|
|---|
| 200 | PTR
|
|---|
| 201 | bfd_zmalloc (size)
|
|---|
| 202 | bfd_size_type size;
|
|---|
| 203 | {
|
|---|
| 204 | PTR ptr;
|
|---|
| 205 |
|
|---|
| 206 | if (size != (size_t) size)
|
|---|
| 207 | {
|
|---|
| 208 | bfd_set_error (bfd_error_no_memory);
|
|---|
| 209 | return NULL;
|
|---|
| 210 | }
|
|---|
| 211 |
|
|---|
| 212 | ptr = (PTR) malloc ((size_t) size);
|
|---|
| 213 |
|
|---|
| 214 | if ((size_t) size != 0)
|
|---|
| 215 | {
|
|---|
| 216 | if (ptr == NULL)
|
|---|
| 217 | bfd_set_error (bfd_error_no_memory);
|
|---|
| 218 | else
|
|---|
| 219 | memset (ptr, 0, (size_t) size);
|
|---|
| 220 | }
|
|---|
| 221 |
|
|---|
| 222 | return ptr;
|
|---|
| 223 | }
|
|---|
| 224 | /*
|
|---|
| 225 | INTERNAL_FUNCTION
|
|---|
| 226 | bfd_write_bigendian_4byte_int
|
|---|
| 227 |
|
|---|
| 228 | SYNOPSIS
|
|---|
| 229 | bfd_boolean bfd_write_bigendian_4byte_int (bfd *, unsigned int);
|
|---|
| 230 |
|
|---|
| 231 | DESCRIPTION
|
|---|
| 232 | Write a 4 byte integer @var{i} to the output BFD @var{abfd}, in big
|
|---|
| 233 | endian order regardless of what else is going on. This is useful in
|
|---|
| 234 | archives.
|
|---|
| 235 |
|
|---|
| 236 | */
|
|---|
| 237 | bfd_boolean
|
|---|
| 238 | bfd_write_bigendian_4byte_int (abfd, i)
|
|---|
| 239 | bfd *abfd;
|
|---|
| 240 | unsigned int i;
|
|---|
| 241 | {
|
|---|
| 242 | bfd_byte buffer[4];
|
|---|
| 243 | bfd_putb32 ((bfd_vma) i, buffer);
|
|---|
| 244 | return bfd_bwrite ((PTR) buffer, (bfd_size_type) 4, abfd) == 4;
|
|---|
| 245 | }
|
|---|
| 246 |
|
|---|
| 247 | |
|---|
| 248 |
|
|---|
| 249 | /** The do-it-yourself (byte) sex-change kit */
|
|---|
| 250 |
|
|---|
| 251 | /* The middle letter e.g. get<b>short indicates Big or Little endian
|
|---|
| 252 | target machine. It doesn't matter what the byte order of the host
|
|---|
| 253 | machine is; these routines work for either. */
|
|---|
| 254 |
|
|---|
| 255 | /* FIXME: Should these take a count argument?
|
|---|
| 256 | Answer (gnu@cygnus.com): No, but perhaps they should be inline
|
|---|
| 257 | functions in swap.h #ifdef __GNUC__.
|
|---|
| 258 | Gprof them later and find out. */
|
|---|
| 259 |
|
|---|
| 260 | /*
|
|---|
| 261 | FUNCTION
|
|---|
| 262 | bfd_put_size
|
|---|
| 263 | FUNCTION
|
|---|
| 264 | bfd_get_size
|
|---|
| 265 |
|
|---|
| 266 | DESCRIPTION
|
|---|
| 267 | These macros as used for reading and writing raw data in
|
|---|
| 268 | sections; each access (except for bytes) is vectored through
|
|---|
| 269 | the target format of the BFD and mangled accordingly. The
|
|---|
| 270 | mangling performs any necessary endian translations and
|
|---|
| 271 | removes alignment restrictions. Note that types accepted and
|
|---|
| 272 | returned by these macros are identical so they can be swapped
|
|---|
| 273 | around in macros---for example, @file{libaout.h} defines <<GET_WORD>>
|
|---|
| 274 | to either <<bfd_get_32>> or <<bfd_get_64>>.
|
|---|
| 275 |
|
|---|
| 276 | In the put routines, @var{val} must be a <<bfd_vma>>. If we are on a
|
|---|
| 277 | system without prototypes, the caller is responsible for making
|
|---|
| 278 | sure that is true, with a cast if necessary. We don't cast
|
|---|
| 279 | them in the macro definitions because that would prevent <<lint>>
|
|---|
| 280 | or <<gcc -Wall>> from detecting sins such as passing a pointer.
|
|---|
| 281 | To detect calling these with less than a <<bfd_vma>>, use
|
|---|
| 282 | <<gcc -Wconversion>> on a host with 64 bit <<bfd_vma>>'s.
|
|---|
| 283 |
|
|---|
| 284 | .
|
|---|
| 285 | .{* Byte swapping macros for user section data. *}
|
|---|
| 286 | .
|
|---|
| 287 | .#define bfd_put_8(abfd, val, ptr) \
|
|---|
| 288 | . ((void) (*((unsigned char *) (ptr)) = (unsigned char) (val)))
|
|---|
| 289 | .#define bfd_put_signed_8 \
|
|---|
| 290 | . bfd_put_8
|
|---|
| 291 | .#define bfd_get_8(abfd, ptr) \
|
|---|
| 292 | . (*(unsigned char *) (ptr) & 0xff)
|
|---|
| 293 | .#define bfd_get_signed_8(abfd, ptr) \
|
|---|
| 294 | . (((*(unsigned char *) (ptr) & 0xff) ^ 0x80) - 0x80)
|
|---|
| 295 | .
|
|---|
| 296 | .#define bfd_put_16(abfd, val, ptr) \
|
|---|
| 297 | . BFD_SEND(abfd, bfd_putx16, ((val),(ptr)))
|
|---|
| 298 | .#define bfd_put_signed_16 \
|
|---|
| 299 | . bfd_put_16
|
|---|
| 300 | .#define bfd_get_16(abfd, ptr) \
|
|---|
| 301 | . BFD_SEND(abfd, bfd_getx16, (ptr))
|
|---|
| 302 | .#define bfd_get_signed_16(abfd, ptr) \
|
|---|
| 303 | . BFD_SEND (abfd, bfd_getx_signed_16, (ptr))
|
|---|
| 304 | .
|
|---|
| 305 | .#define bfd_put_32(abfd, val, ptr) \
|
|---|
| 306 | . BFD_SEND(abfd, bfd_putx32, ((val),(ptr)))
|
|---|
| 307 | .#define bfd_put_signed_32 \
|
|---|
| 308 | . bfd_put_32
|
|---|
| 309 | .#define bfd_get_32(abfd, ptr) \
|
|---|
| 310 | . BFD_SEND(abfd, bfd_getx32, (ptr))
|
|---|
| 311 | .#define bfd_get_signed_32(abfd, ptr) \
|
|---|
| 312 | . BFD_SEND(abfd, bfd_getx_signed_32, (ptr))
|
|---|
| 313 | .
|
|---|
| 314 | .#define bfd_put_64(abfd, val, ptr) \
|
|---|
| 315 | . BFD_SEND(abfd, bfd_putx64, ((val), (ptr)))
|
|---|
| 316 | .#define bfd_put_signed_64 \
|
|---|
| 317 | . bfd_put_64
|
|---|
| 318 | .#define bfd_get_64(abfd, ptr) \
|
|---|
| 319 | . BFD_SEND(abfd, bfd_getx64, (ptr))
|
|---|
| 320 | .#define bfd_get_signed_64(abfd, ptr) \
|
|---|
| 321 | . BFD_SEND(abfd, bfd_getx_signed_64, (ptr))
|
|---|
| 322 | .
|
|---|
| 323 | .#define bfd_get(bits, abfd, ptr) \
|
|---|
| 324 | . ( (bits) == 8 ? (bfd_vma) bfd_get_8 (abfd, ptr) \
|
|---|
| 325 | . : (bits) == 16 ? bfd_get_16 (abfd, ptr) \
|
|---|
| 326 | . : (bits) == 32 ? bfd_get_32 (abfd, ptr) \
|
|---|
| 327 | . : (bits) == 64 ? bfd_get_64 (abfd, ptr) \
|
|---|
| 328 | . : (abort (), (bfd_vma) - 1))
|
|---|
| 329 | .
|
|---|
| 330 | .#define bfd_put(bits, abfd, val, ptr) \
|
|---|
| 331 | . ( (bits) == 8 ? bfd_put_8 (abfd, val, ptr) \
|
|---|
| 332 | . : (bits) == 16 ? bfd_put_16 (abfd, val, ptr) \
|
|---|
| 333 | . : (bits) == 32 ? bfd_put_32 (abfd, val, ptr) \
|
|---|
| 334 | . : (bits) == 64 ? bfd_put_64 (abfd, val, ptr) \
|
|---|
| 335 | . : (abort (), (void) 0))
|
|---|
| 336 | .
|
|---|
| 337 | */
|
|---|
| 338 |
|
|---|
| 339 | /*
|
|---|
| 340 | FUNCTION
|
|---|
| 341 | bfd_h_put_size
|
|---|
| 342 | bfd_h_get_size
|
|---|
| 343 |
|
|---|
| 344 | DESCRIPTION
|
|---|
| 345 | These macros have the same function as their <<bfd_get_x>>
|
|---|
| 346 | brethren, except that they are used for removing information
|
|---|
| 347 | for the header records of object files. Believe it or not,
|
|---|
| 348 | some object files keep their header records in big endian
|
|---|
| 349 | order and their data in little endian order.
|
|---|
| 350 | .
|
|---|
| 351 | .{* Byte swapping macros for file header data. *}
|
|---|
| 352 | .
|
|---|
| 353 | .#define bfd_h_put_8(abfd, val, ptr) \
|
|---|
| 354 | . bfd_put_8 (abfd, val, ptr)
|
|---|
| 355 | .#define bfd_h_put_signed_8(abfd, val, ptr) \
|
|---|
| 356 | . bfd_put_8 (abfd, val, ptr)
|
|---|
| 357 | .#define bfd_h_get_8(abfd, ptr) \
|
|---|
| 358 | . bfd_get_8 (abfd, ptr)
|
|---|
| 359 | .#define bfd_h_get_signed_8(abfd, ptr) \
|
|---|
| 360 | . bfd_get_signed_8 (abfd, ptr)
|
|---|
| 361 | .
|
|---|
| 362 | .#define bfd_h_put_16(abfd, val, ptr) \
|
|---|
| 363 | . BFD_SEND (abfd, bfd_h_putx16, (val, ptr))
|
|---|
| 364 | .#define bfd_h_put_signed_16 \
|
|---|
| 365 | . bfd_h_put_16
|
|---|
| 366 | .#define bfd_h_get_16(abfd, ptr) \
|
|---|
| 367 | . BFD_SEND (abfd, bfd_h_getx16, (ptr))
|
|---|
| 368 | .#define bfd_h_get_signed_16(abfd, ptr) \
|
|---|
| 369 | . BFD_SEND (abfd, bfd_h_getx_signed_16, (ptr))
|
|---|
| 370 | .
|
|---|
| 371 | .#define bfd_h_put_32(abfd, val, ptr) \
|
|---|
| 372 | . BFD_SEND (abfd, bfd_h_putx32, (val, ptr))
|
|---|
| 373 | .#define bfd_h_put_signed_32 \
|
|---|
| 374 | . bfd_h_put_32
|
|---|
| 375 | .#define bfd_h_get_32(abfd, ptr) \
|
|---|
| 376 | . BFD_SEND (abfd, bfd_h_getx32, (ptr))
|
|---|
| 377 | .#define bfd_h_get_signed_32(abfd, ptr) \
|
|---|
| 378 | . BFD_SEND (abfd, bfd_h_getx_signed_32, (ptr))
|
|---|
| 379 | .
|
|---|
| 380 | .#define bfd_h_put_64(abfd, val, ptr) \
|
|---|
| 381 | . BFD_SEND (abfd, bfd_h_putx64, (val, ptr))
|
|---|
| 382 | .#define bfd_h_put_signed_64 \
|
|---|
| 383 | . bfd_h_put_64
|
|---|
| 384 | .#define bfd_h_get_64(abfd, ptr) \
|
|---|
| 385 | . BFD_SEND (abfd, bfd_h_getx64, (ptr))
|
|---|
| 386 | .#define bfd_h_get_signed_64(abfd, ptr) \
|
|---|
| 387 | . BFD_SEND (abfd, bfd_h_getx_signed_64, (ptr))
|
|---|
| 388 | .
|
|---|
| 389 | .{* Refinements on the above, which should eventually go away. Save
|
|---|
| 390 | . cluttering the source with (bfd_vma) and (bfd_byte *) casts. *}
|
|---|
| 391 | .
|
|---|
| 392 | .#define H_PUT_64(abfd, val, where) \
|
|---|
| 393 | . bfd_h_put_64 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
|
|---|
| 394 | .
|
|---|
| 395 | .#define H_PUT_32(abfd, val, where) \
|
|---|
| 396 | . bfd_h_put_32 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
|
|---|
| 397 | .
|
|---|
| 398 | .#define H_PUT_16(abfd, val, where) \
|
|---|
| 399 | . bfd_h_put_16 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
|
|---|
| 400 | .
|
|---|
| 401 | .#define H_PUT_8 bfd_h_put_8
|
|---|
| 402 | .
|
|---|
| 403 | .#define H_PUT_S64(abfd, val, where) \
|
|---|
| 404 | . bfd_h_put_signed_64 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
|
|---|
| 405 | .
|
|---|
| 406 | .#define H_PUT_S32(abfd, val, where) \
|
|---|
| 407 | . bfd_h_put_signed_32 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
|
|---|
| 408 | .
|
|---|
| 409 | .#define H_PUT_S16(abfd, val, where) \
|
|---|
| 410 | . bfd_h_put_signed_16 ((abfd), (bfd_vma) (val), (bfd_byte *) (where))
|
|---|
| 411 | .
|
|---|
| 412 | .#define H_PUT_S8 bfd_h_put_signed_8
|
|---|
| 413 | .
|
|---|
| 414 | .#define H_GET_64(abfd, where) \
|
|---|
| 415 | . bfd_h_get_64 ((abfd), (bfd_byte *) (where))
|
|---|
| 416 | .
|
|---|
| 417 | .#define H_GET_32(abfd, where) \
|
|---|
| 418 | . bfd_h_get_32 ((abfd), (bfd_byte *) (where))
|
|---|
| 419 | .
|
|---|
| 420 | .#define H_GET_16(abfd, where) \
|
|---|
| 421 | . bfd_h_get_16 ((abfd), (bfd_byte *) (where))
|
|---|
| 422 | .
|
|---|
| 423 | .#define H_GET_8 bfd_h_get_8
|
|---|
| 424 | .
|
|---|
| 425 | .#define H_GET_S64(abfd, where) \
|
|---|
| 426 | . bfd_h_get_signed_64 ((abfd), (bfd_byte *) (where))
|
|---|
| 427 | .
|
|---|
| 428 | .#define H_GET_S32(abfd, where) \
|
|---|
| 429 | . bfd_h_get_signed_32 ((abfd), (bfd_byte *) (where))
|
|---|
| 430 | .
|
|---|
| 431 | .#define H_GET_S16(abfd, where) \
|
|---|
| 432 | . bfd_h_get_signed_16 ((abfd), (bfd_byte *) (where))
|
|---|
| 433 | .
|
|---|
| 434 | .#define H_GET_S8 bfd_h_get_signed_8
|
|---|
| 435 | .
|
|---|
| 436 | .*/
|
|---|
| 437 |
|
|---|
| 438 | /* Sign extension to bfd_signed_vma. */
|
|---|
| 439 | #define COERCE16(x) (((bfd_signed_vma) (x) ^ 0x8000) - 0x8000)
|
|---|
| 440 | #define COERCE32(x) \
|
|---|
| 441 | ((bfd_signed_vma) (long) (((unsigned long) (x) ^ 0x80000000) - 0x80000000))
|
|---|
| 442 | #define EIGHT_GAZILLION (((BFD_HOST_64_BIT)0x80000000) << 32)
|
|---|
| 443 | #define COERCE64(x) \
|
|---|
| 444 | (((bfd_signed_vma) (x) ^ EIGHT_GAZILLION) - EIGHT_GAZILLION)
|
|---|
| 445 |
|
|---|
| 446 | bfd_vma
|
|---|
| 447 | bfd_getb16 (addr)
|
|---|
| 448 | register const bfd_byte *addr;
|
|---|
| 449 | {
|
|---|
| 450 | return (addr[0] << 8) | addr[1];
|
|---|
| 451 | }
|
|---|
| 452 |
|
|---|
| 453 | bfd_vma
|
|---|
| 454 | bfd_getl16 (addr)
|
|---|
| 455 | register const bfd_byte *addr;
|
|---|
| 456 | {
|
|---|
| 457 | return (addr[1] << 8) | addr[0];
|
|---|
| 458 | }
|
|---|
| 459 |
|
|---|
| 460 | bfd_signed_vma
|
|---|
| 461 | bfd_getb_signed_16 (addr)
|
|---|
| 462 | register const bfd_byte *addr;
|
|---|
| 463 | {
|
|---|
| 464 | return COERCE16((addr[0] << 8) | addr[1]);
|
|---|
| 465 | }
|
|---|
| 466 |
|
|---|
| 467 | bfd_signed_vma
|
|---|
| 468 | bfd_getl_signed_16 (addr)
|
|---|
| 469 | register const bfd_byte *addr;
|
|---|
| 470 | {
|
|---|
| 471 | return COERCE16((addr[1] << 8) | addr[0]);
|
|---|
| 472 | }
|
|---|
| 473 |
|
|---|
| 474 | void
|
|---|
| 475 | bfd_putb16 (data, addr)
|
|---|
| 476 | bfd_vma data;
|
|---|
| 477 | register bfd_byte *addr;
|
|---|
| 478 | {
|
|---|
| 479 | addr[0] = (bfd_byte) (data >> 8);
|
|---|
| 480 | addr[1] = (bfd_byte) data;
|
|---|
| 481 | }
|
|---|
| 482 |
|
|---|
| 483 | void
|
|---|
| 484 | bfd_putl16 (data, addr)
|
|---|
| 485 | bfd_vma data;
|
|---|
| 486 | register bfd_byte *addr;
|
|---|
| 487 | {
|
|---|
| 488 | addr[0] = (bfd_byte) data;
|
|---|
| 489 | addr[1] = (bfd_byte) (data >> 8);
|
|---|
| 490 | }
|
|---|
| 491 |
|
|---|
| 492 | bfd_vma
|
|---|
| 493 | bfd_getb32 (addr)
|
|---|
| 494 | register const bfd_byte *addr;
|
|---|
| 495 | {
|
|---|
| 496 | unsigned long v;
|
|---|
| 497 |
|
|---|
| 498 | v = (unsigned long) addr[0] << 24;
|
|---|
| 499 | v |= (unsigned long) addr[1] << 16;
|
|---|
| 500 | v |= (unsigned long) addr[2] << 8;
|
|---|
| 501 | v |= (unsigned long) addr[3];
|
|---|
| 502 | return (bfd_vma) v;
|
|---|
| 503 | }
|
|---|
| 504 |
|
|---|
| 505 | bfd_vma
|
|---|
| 506 | bfd_getl32 (addr)
|
|---|
| 507 | register const bfd_byte *addr;
|
|---|
| 508 | {
|
|---|
| 509 | unsigned long v;
|
|---|
| 510 |
|
|---|
| 511 | v = (unsigned long) addr[0];
|
|---|
| 512 | v |= (unsigned long) addr[1] << 8;
|
|---|
| 513 | v |= (unsigned long) addr[2] << 16;
|
|---|
| 514 | v |= (unsigned long) addr[3] << 24;
|
|---|
| 515 | return (bfd_vma) v;
|
|---|
| 516 | }
|
|---|
| 517 |
|
|---|
| 518 | bfd_signed_vma
|
|---|
| 519 | bfd_getb_signed_32 (addr)
|
|---|
| 520 | register const bfd_byte *addr;
|
|---|
| 521 | {
|
|---|
| 522 | unsigned long v;
|
|---|
| 523 |
|
|---|
| 524 | v = (unsigned long) addr[0] << 24;
|
|---|
| 525 | v |= (unsigned long) addr[1] << 16;
|
|---|
| 526 | v |= (unsigned long) addr[2] << 8;
|
|---|
| 527 | v |= (unsigned long) addr[3];
|
|---|
| 528 | return COERCE32 (v);
|
|---|
| 529 | }
|
|---|
| 530 |
|
|---|
| 531 | bfd_signed_vma
|
|---|
| 532 | bfd_getl_signed_32 (addr)
|
|---|
| 533 | register const bfd_byte *addr;
|
|---|
| 534 | {
|
|---|
| 535 | unsigned long v;
|
|---|
| 536 |
|
|---|
| 537 | v = (unsigned long) addr[0];
|
|---|
| 538 | v |= (unsigned long) addr[1] << 8;
|
|---|
| 539 | v |= (unsigned long) addr[2] << 16;
|
|---|
| 540 | v |= (unsigned long) addr[3] << 24;
|
|---|
| 541 | return COERCE32 (v);
|
|---|
| 542 | }
|
|---|
| 543 |
|
|---|
| 544 | bfd_vma
|
|---|
| 545 | bfd_getb64 (addr)
|
|---|
| 546 | register const bfd_byte *addr ATTRIBUTE_UNUSED;
|
|---|
| 547 | {
|
|---|
| 548 | #ifdef BFD64
|
|---|
| 549 | bfd_vma low, high;
|
|---|
| 550 |
|
|---|
| 551 | high= ((((((((addr[0]) << 8) |
|
|---|
| 552 | addr[1]) << 8) |
|
|---|
| 553 | addr[2]) << 8) |
|
|---|
| 554 | addr[3]) );
|
|---|
| 555 |
|
|---|
| 556 | low = (((((((((bfd_vma)addr[4]) << 8) |
|
|---|
| 557 | addr[5]) << 8) |
|
|---|
| 558 | addr[6]) << 8) |
|
|---|
| 559 | addr[7]));
|
|---|
| 560 |
|
|---|
| 561 | return high << 32 | low;
|
|---|
| 562 | #else
|
|---|
| 563 | BFD_FAIL();
|
|---|
| 564 | return 0;
|
|---|
| 565 | #endif
|
|---|
| 566 | }
|
|---|
| 567 |
|
|---|
| 568 | bfd_vma
|
|---|
| 569 | bfd_getl64 (addr)
|
|---|
| 570 | register const bfd_byte *addr ATTRIBUTE_UNUSED;
|
|---|
| 571 | {
|
|---|
| 572 | #ifdef BFD64
|
|---|
| 573 | bfd_vma low, high;
|
|---|
| 574 | high= (((((((addr[7] << 8) |
|
|---|
| 575 | addr[6]) << 8) |
|
|---|
| 576 | addr[5]) << 8) |
|
|---|
| 577 | addr[4]));
|
|---|
| 578 |
|
|---|
| 579 | low = ((((((((bfd_vma)addr[3] << 8) |
|
|---|
| 580 | addr[2]) << 8) |
|
|---|
| 581 | addr[1]) << 8) |
|
|---|
| 582 | addr[0]) );
|
|---|
| 583 |
|
|---|
| 584 | return high << 32 | low;
|
|---|
| 585 | #else
|
|---|
| 586 | BFD_FAIL();
|
|---|
| 587 | return 0;
|
|---|
| 588 | #endif
|
|---|
| 589 |
|
|---|
| 590 | }
|
|---|
| 591 |
|
|---|
| 592 | bfd_signed_vma
|
|---|
| 593 | bfd_getb_signed_64 (addr)
|
|---|
| 594 | register const bfd_byte *addr ATTRIBUTE_UNUSED;
|
|---|
| 595 | {
|
|---|
| 596 | #ifdef BFD64
|
|---|
| 597 | bfd_vma low, high;
|
|---|
| 598 |
|
|---|
| 599 | high= ((((((((addr[0]) << 8) |
|
|---|
| 600 | addr[1]) << 8) |
|
|---|
| 601 | addr[2]) << 8) |
|
|---|
| 602 | addr[3]) );
|
|---|
| 603 |
|
|---|
| 604 | low = (((((((((bfd_vma)addr[4]) << 8) |
|
|---|
| 605 | addr[5]) << 8) |
|
|---|
| 606 | addr[6]) << 8) |
|
|---|
| 607 | addr[7]));
|
|---|
| 608 |
|
|---|
| 609 | return COERCE64(high << 32 | low);
|
|---|
| 610 | #else
|
|---|
| 611 | BFD_FAIL();
|
|---|
| 612 | return 0;
|
|---|
| 613 | #endif
|
|---|
| 614 | }
|
|---|
| 615 |
|
|---|
| 616 | bfd_signed_vma
|
|---|
| 617 | bfd_getl_signed_64 (addr)
|
|---|
| 618 | register const bfd_byte *addr ATTRIBUTE_UNUSED;
|
|---|
| 619 | {
|
|---|
| 620 | #ifdef BFD64
|
|---|
| 621 | bfd_vma low, high;
|
|---|
| 622 | high= (((((((addr[7] << 8) |
|
|---|
| 623 | addr[6]) << 8) |
|
|---|
| 624 | addr[5]) << 8) |
|
|---|
| 625 | addr[4]));
|
|---|
| 626 |
|
|---|
| 627 | low = ((((((((bfd_vma)addr[3] << 8) |
|
|---|
| 628 | addr[2]) << 8) |
|
|---|
| 629 | addr[1]) << 8) |
|
|---|
| 630 | addr[0]) );
|
|---|
| 631 |
|
|---|
| 632 | return COERCE64(high << 32 | low);
|
|---|
| 633 | #else
|
|---|
| 634 | BFD_FAIL();
|
|---|
| 635 | return 0;
|
|---|
| 636 | #endif
|
|---|
| 637 | }
|
|---|
| 638 |
|
|---|
| 639 | void
|
|---|
| 640 | bfd_putb32 (data, addr)
|
|---|
| 641 | bfd_vma data;
|
|---|
| 642 | register bfd_byte *addr;
|
|---|
| 643 | {
|
|---|
| 644 | addr[0] = (bfd_byte) (data >> 24);
|
|---|
| 645 | addr[1] = (bfd_byte) (data >> 16);
|
|---|
| 646 | addr[2] = (bfd_byte) (data >> 8);
|
|---|
| 647 | addr[3] = (bfd_byte) data;
|
|---|
| 648 | }
|
|---|
| 649 |
|
|---|
| 650 | void
|
|---|
| 651 | bfd_putl32 (data, addr)
|
|---|
| 652 | bfd_vma data;
|
|---|
| 653 | register bfd_byte *addr;
|
|---|
| 654 | {
|
|---|
| 655 | addr[0] = (bfd_byte) data;
|
|---|
| 656 | addr[1] = (bfd_byte) (data >> 8);
|
|---|
| 657 | addr[2] = (bfd_byte) (data >> 16);
|
|---|
| 658 | addr[3] = (bfd_byte) (data >> 24);
|
|---|
| 659 | }
|
|---|
| 660 |
|
|---|
| 661 | void
|
|---|
| 662 | bfd_putb64 (data, addr)
|
|---|
| 663 | bfd_vma data ATTRIBUTE_UNUSED;
|
|---|
| 664 | register bfd_byte *addr ATTRIBUTE_UNUSED;
|
|---|
| 665 | {
|
|---|
| 666 | #ifdef BFD64
|
|---|
| 667 | addr[0] = (bfd_byte) (data >> (7*8));
|
|---|
| 668 | addr[1] = (bfd_byte) (data >> (6*8));
|
|---|
| 669 | addr[2] = (bfd_byte) (data >> (5*8));
|
|---|
| 670 | addr[3] = (bfd_byte) (data >> (4*8));
|
|---|
| 671 | addr[4] = (bfd_byte) (data >> (3*8));
|
|---|
| 672 | addr[5] = (bfd_byte) (data >> (2*8));
|
|---|
| 673 | addr[6] = (bfd_byte) (data >> (1*8));
|
|---|
| 674 | addr[7] = (bfd_byte) (data >> (0*8));
|
|---|
| 675 | #else
|
|---|
| 676 | BFD_FAIL();
|
|---|
| 677 | #endif
|
|---|
| 678 | }
|
|---|
| 679 |
|
|---|
| 680 | void
|
|---|
| 681 | bfd_putl64 (data, addr)
|
|---|
| 682 | bfd_vma data ATTRIBUTE_UNUSED;
|
|---|
| 683 | register bfd_byte *addr ATTRIBUTE_UNUSED;
|
|---|
| 684 | {
|
|---|
| 685 | #ifdef BFD64
|
|---|
| 686 | addr[7] = (bfd_byte) (data >> (7*8));
|
|---|
| 687 | addr[6] = (bfd_byte) (data >> (6*8));
|
|---|
| 688 | addr[5] = (bfd_byte) (data >> (5*8));
|
|---|
| 689 | addr[4] = (bfd_byte) (data >> (4*8));
|
|---|
| 690 | addr[3] = (bfd_byte) (data >> (3*8));
|
|---|
| 691 | addr[2] = (bfd_byte) (data >> (2*8));
|
|---|
| 692 | addr[1] = (bfd_byte) (data >> (1*8));
|
|---|
| 693 | addr[0] = (bfd_byte) (data >> (0*8));
|
|---|
| 694 | #else
|
|---|
| 695 | BFD_FAIL();
|
|---|
| 696 | #endif
|
|---|
| 697 | }
|
|---|
| 698 |
|
|---|
| 699 | void
|
|---|
| 700 | bfd_put_bits (data, addr, bits, big_p)
|
|---|
| 701 | bfd_vma data;
|
|---|
| 702 | bfd_byte *addr;
|
|---|
| 703 | int bits;
|
|---|
| 704 | bfd_boolean big_p;
|
|---|
| 705 | {
|
|---|
| 706 | int i;
|
|---|
| 707 | int bytes;
|
|---|
| 708 |
|
|---|
| 709 | if (bits % 8 != 0)
|
|---|
| 710 | abort ();
|
|---|
| 711 |
|
|---|
| 712 | bytes = bits / 8;
|
|---|
| 713 | for (i = 0; i < bytes; i++)
|
|---|
| 714 | {
|
|---|
| 715 | int index = big_p ? bytes - i - 1 : i;
|
|---|
| 716 |
|
|---|
| 717 | addr[index] = (bfd_byte) data;
|
|---|
| 718 | data >>= 8;
|
|---|
| 719 | }
|
|---|
| 720 | }
|
|---|
| 721 |
|
|---|
| 722 | bfd_vma
|
|---|
| 723 | bfd_get_bits (addr, bits, big_p)
|
|---|
| 724 | bfd_byte *addr;
|
|---|
| 725 | int bits;
|
|---|
| 726 | bfd_boolean big_p;
|
|---|
| 727 | {
|
|---|
| 728 | bfd_vma data;
|
|---|
| 729 | int i;
|
|---|
| 730 | int bytes;
|
|---|
| 731 |
|
|---|
| 732 | if (bits % 8 != 0)
|
|---|
| 733 | abort ();
|
|---|
| 734 |
|
|---|
| 735 | data = 0;
|
|---|
| 736 | bytes = bits / 8;
|
|---|
| 737 | for (i = 0; i < bytes; i++)
|
|---|
| 738 | {
|
|---|
| 739 | int index = big_p ? i : bytes - i - 1;
|
|---|
| 740 |
|
|---|
| 741 | data = (data << 8) | addr[index];
|
|---|
| 742 | }
|
|---|
| 743 |
|
|---|
| 744 | return data;
|
|---|
| 745 | }
|
|---|
| 746 | |
|---|
| 747 |
|
|---|
| 748 | /* Default implementation */
|
|---|
| 749 |
|
|---|
| 750 | bfd_boolean
|
|---|
| 751 | _bfd_generic_get_section_contents (abfd, section, location, offset, count)
|
|---|
| 752 | bfd *abfd;
|
|---|
| 753 | sec_ptr section;
|
|---|
| 754 | PTR location;
|
|---|
| 755 | file_ptr offset;
|
|---|
| 756 | bfd_size_type count;
|
|---|
| 757 | {
|
|---|
| 758 | if (count == 0)
|
|---|
| 759 | return TRUE;
|
|---|
| 760 |
|
|---|
| 761 | if (offset + count > section->_raw_size)
|
|---|
| 762 | {
|
|---|
| 763 | bfd_set_error (bfd_error_invalid_operation);
|
|---|
| 764 | return FALSE;
|
|---|
| 765 | }
|
|---|
| 766 |
|
|---|
| 767 | if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0
|
|---|
| 768 | || bfd_bread (location, count, abfd) != count)
|
|---|
| 769 | return FALSE;
|
|---|
| 770 |
|
|---|
| 771 | return TRUE;
|
|---|
| 772 | }
|
|---|
| 773 |
|
|---|
| 774 | bfd_boolean
|
|---|
| 775 | _bfd_generic_get_section_contents_in_window (abfd, section, w, offset, count)
|
|---|
| 776 | bfd *abfd ATTRIBUTE_UNUSED;
|
|---|
| 777 | sec_ptr section ATTRIBUTE_UNUSED;
|
|---|
| 778 | bfd_window *w ATTRIBUTE_UNUSED;
|
|---|
| 779 | file_ptr offset ATTRIBUTE_UNUSED;
|
|---|
| 780 | bfd_size_type count ATTRIBUTE_UNUSED;
|
|---|
| 781 | {
|
|---|
| 782 | #ifdef USE_MMAP
|
|---|
| 783 | if (count == 0)
|
|---|
| 784 | return TRUE;
|
|---|
| 785 | if (abfd->xvec->_bfd_get_section_contents != _bfd_generic_get_section_contents)
|
|---|
| 786 | {
|
|---|
| 787 | /* We don't know what changes the bfd's get_section_contents
|
|---|
| 788 | method may have to make. So punt trying to map the file
|
|---|
| 789 | window, and let get_section_contents do its thing. */
|
|---|
| 790 | /* @@ FIXME : If the internal window has a refcount of 1 and was
|
|---|
| 791 | allocated with malloc instead of mmap, just reuse it. */
|
|---|
| 792 | bfd_free_window (w);
|
|---|
| 793 | w->i = ((bfd_window_internal *)
|
|---|
| 794 | bfd_zmalloc ((bfd_size_type) sizeof (bfd_window_internal)));
|
|---|
| 795 | if (w->i == NULL)
|
|---|
| 796 | return FALSE;
|
|---|
| 797 | w->i->data = (PTR) bfd_malloc (count);
|
|---|
| 798 | if (w->i->data == NULL)
|
|---|
| 799 | {
|
|---|
| 800 | free (w->i);
|
|---|
| 801 | w->i = NULL;
|
|---|
| 802 | return FALSE;
|
|---|
| 803 | }
|
|---|
| 804 | w->i->mapped = 0;
|
|---|
| 805 | w->i->refcount = 1;
|
|---|
| 806 | w->size = w->i->size = count;
|
|---|
| 807 | w->data = w->i->data;
|
|---|
| 808 | return bfd_get_section_contents (abfd, section, w->data, offset, count);
|
|---|
| 809 | }
|
|---|
| 810 | if (offset + count > section->_raw_size
|
|---|
| 811 | || ! bfd_get_file_window (abfd, section->filepos + offset, count, w,
|
|---|
| 812 | TRUE))
|
|---|
| 813 | return FALSE;
|
|---|
| 814 | return TRUE;
|
|---|
| 815 | #else
|
|---|
| 816 | abort ();
|
|---|
| 817 | #endif
|
|---|
| 818 | }
|
|---|
| 819 |
|
|---|
| 820 | /* This generic function can only be used in implementations where creating
|
|---|
| 821 | NEW sections is disallowed. It is useful in patching existing sections
|
|---|
| 822 | in read-write files, though. See other set_section_contents functions
|
|---|
| 823 | to see why it doesn't work for new sections. */
|
|---|
| 824 | bfd_boolean
|
|---|
| 825 | _bfd_generic_set_section_contents (abfd, section, location, offset, count)
|
|---|
| 826 | bfd *abfd;
|
|---|
| 827 | sec_ptr section;
|
|---|
| 828 | PTR location;
|
|---|
| 829 | file_ptr offset;
|
|---|
| 830 | bfd_size_type count;
|
|---|
| 831 | {
|
|---|
| 832 | if (count == 0)
|
|---|
| 833 | return TRUE;
|
|---|
| 834 |
|
|---|
| 835 | if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0
|
|---|
| 836 | || bfd_bwrite (location, count, abfd) != count)
|
|---|
| 837 | return FALSE;
|
|---|
| 838 |
|
|---|
| 839 | return TRUE;
|
|---|
| 840 | }
|
|---|
| 841 |
|
|---|
| 842 | /*
|
|---|
| 843 | INTERNAL_FUNCTION
|
|---|
| 844 | bfd_log2
|
|---|
| 845 |
|
|---|
| 846 | SYNOPSIS
|
|---|
| 847 | unsigned int bfd_log2 (bfd_vma x);
|
|---|
| 848 |
|
|---|
| 849 | DESCRIPTION
|
|---|
| 850 | Return the log base 2 of the value supplied, rounded up. E.g., an
|
|---|
| 851 | @var{x} of 1025 returns 11. A @var{x} of 0 returns 0.
|
|---|
| 852 | */
|
|---|
| 853 |
|
|---|
| 854 | unsigned int
|
|---|
| 855 | bfd_log2 (x)
|
|---|
| 856 | bfd_vma x;
|
|---|
| 857 | {
|
|---|
| 858 | unsigned int result = 0;
|
|---|
| 859 |
|
|---|
| 860 | while ((x = (x >> 1)) != 0)
|
|---|
| 861 | ++result;
|
|---|
| 862 | return result;
|
|---|
| 863 | }
|
|---|
| 864 |
|
|---|
| 865 | bfd_boolean
|
|---|
| 866 | bfd_generic_is_local_label_name (abfd, name)
|
|---|
| 867 | bfd *abfd;
|
|---|
| 868 | const char *name;
|
|---|
| 869 | {
|
|---|
| 870 | char locals_prefix = (bfd_get_symbol_leading_char (abfd) == '_') ? 'L' : '.';
|
|---|
| 871 |
|
|---|
| 872 | return name[0] == locals_prefix;
|
|---|
| 873 | }
|
|---|
| 874 |
|
|---|
| 875 | /* Can be used from / for bfd_merge_private_bfd_data to check that
|
|---|
| 876 | endianness matches between input and output file. Returns
|
|---|
| 877 | TRUE for a match, otherwise returns FALSE and emits an error. */
|
|---|
| 878 | bfd_boolean
|
|---|
| 879 | _bfd_generic_verify_endian_match (ibfd, obfd)
|
|---|
| 880 | bfd *ibfd;
|
|---|
| 881 | bfd *obfd;
|
|---|
| 882 | {
|
|---|
| 883 | if (ibfd->xvec->byteorder != obfd->xvec->byteorder
|
|---|
| 884 | && ibfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN
|
|---|
| 885 | && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN)
|
|---|
| 886 | {
|
|---|
| 887 | const char *msg;
|
|---|
| 888 |
|
|---|
| 889 | if (bfd_big_endian (ibfd))
|
|---|
| 890 | msg = _("%s: compiled for a big endian system and target is little endian");
|
|---|
| 891 | else
|
|---|
| 892 | msg = _("%s: compiled for a little endian system and target is big endian");
|
|---|
| 893 |
|
|---|
| 894 | (*_bfd_error_handler) (msg, bfd_archive_filename (ibfd));
|
|---|
| 895 |
|
|---|
| 896 | bfd_set_error (bfd_error_wrong_format);
|
|---|
| 897 | return FALSE;
|
|---|
| 898 | }
|
|---|
| 899 |
|
|---|
| 900 | return TRUE;
|
|---|
| 901 | }
|
|---|
| 902 |
|
|---|
| 903 | /* Give a warning at runtime if someone compiles code which calls
|
|---|
| 904 | old routines. */
|
|---|
| 905 |
|
|---|
| 906 | void
|
|---|
| 907 | warn_deprecated (what, file, line, func)
|
|---|
| 908 | const char *what;
|
|---|
| 909 | const char *file;
|
|---|
| 910 | int line;
|
|---|
| 911 | const char *func;
|
|---|
| 912 | {
|
|---|
| 913 | /* Poor man's tracking of functions we've already warned about. */
|
|---|
| 914 | static size_t mask = 0;
|
|---|
| 915 |
|
|---|
| 916 | if (~(size_t) func & ~mask)
|
|---|
| 917 | {
|
|---|
| 918 | /* Note: separate sentences in order to allow
|
|---|
| 919 | for translation into other languages. */
|
|---|
| 920 | if (func)
|
|---|
| 921 | fprintf (stderr, _("Deprecated %s called at %s line %d in %s\n"),
|
|---|
| 922 | what, file, line, func);
|
|---|
| 923 | else
|
|---|
| 924 | fprintf (stderr, _("Deprecated %s called\n"), what);
|
|---|
| 925 | mask |= ~(size_t) func;
|
|---|
| 926 | }
|
|---|
| 927 | }
|
|---|