133965Sjdp/* Assorted BFD support routines, only used internally. 278828Sobrien Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 3218822Sdim 2000, 2001, 2002, 2003, 2004, 2005, 2007 438889Sjdp Free Software Foundation, Inc. 533965Sjdp Written by Cygnus Support. 633965Sjdp 791041Sobrien This file is part of BFD, the Binary File Descriptor library. 833965Sjdp 991041Sobrien This program is free software; you can redistribute it and/or modify 1091041Sobrien it under the terms of the GNU General Public License as published by 1191041Sobrien the Free Software Foundation; either version 2 of the License, or 1291041Sobrien (at your option) any later version. 1333965Sjdp 1491041Sobrien This program is distributed in the hope that it will be useful, 1591041Sobrien but WITHOUT ANY WARRANTY; without even the implied warranty of 1691041Sobrien MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1791041Sobrien GNU General Public License for more details. 1833965Sjdp 1991041Sobrien You should have received a copy of the GNU General Public License 2091041Sobrien along with this program; if not, write to the Free Software 21218822Sdim Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 2233965Sjdp 23218822Sdim#include "sysdep.h" 2433965Sjdp#include "bfd.h" 2533965Sjdp#include "libbfd.h" 2633965Sjdp 2733965Sjdp#ifndef HAVE_GETPAGESIZE 2833965Sjdp#define getpagesize() 2048 2933965Sjdp#endif 3033965Sjdp 3133965Sjdp/* 3233965SjdpSECTION 33218822Sdim Implementation details 34218822Sdim 35218822SdimSUBSECTION 3633965Sjdp Internal functions 3733965Sjdp 3833965SjdpDESCRIPTION 3933965Sjdp These routines are used within BFD. 4033965Sjdp They are not intended for export, but are documented here for 4133965Sjdp completeness. 4233965Sjdp*/ 4333965Sjdp 4433965Sjdp/* A routine which is used in target vectors for unsupported 4533965Sjdp operations. */ 4633965Sjdp 47130561Sobrienbfd_boolean 48130561Sobrienbfd_false (bfd *ignore ATTRIBUTE_UNUSED) 4933965Sjdp{ 5033965Sjdp bfd_set_error (bfd_error_invalid_operation); 51130561Sobrien return FALSE; 5233965Sjdp} 5333965Sjdp 5433965Sjdp/* A routine which is used in target vectors for supported operations 5533965Sjdp which do not actually do anything. */ 5633965Sjdp 57130561Sobrienbfd_boolean 58130561Sobrienbfd_true (bfd *ignore ATTRIBUTE_UNUSED) 5933965Sjdp{ 60130561Sobrien return TRUE; 6133965Sjdp} 6233965Sjdp 6333965Sjdp/* A routine which is used in target vectors for unsupported 6433965Sjdp operations which return a pointer value. */ 6533965Sjdp 66130561Sobrienvoid * 67130561Sobrienbfd_nullvoidptr (bfd *ignore ATTRIBUTE_UNUSED) 6833965Sjdp{ 6933965Sjdp bfd_set_error (bfd_error_invalid_operation); 7033965Sjdp return NULL; 7133965Sjdp} 7233965Sjdp 7377298Sobrienint 74130561Sobrienbfd_0 (bfd *ignore ATTRIBUTE_UNUSED) 7533965Sjdp{ 7633965Sjdp return 0; 7733965Sjdp} 7833965Sjdp 7977298Sobrienunsigned int 80130561Sobrienbfd_0u (bfd *ignore ATTRIBUTE_UNUSED) 8133965Sjdp{ 8233965Sjdp return 0; 8333965Sjdp} 8433965Sjdp 8533965Sjdplong 86130561Sobrienbfd_0l (bfd *ignore ATTRIBUTE_UNUSED) 8733965Sjdp{ 8833965Sjdp return 0; 8933965Sjdp} 9033965Sjdp 9133965Sjdp/* A routine which is used in target vectors for unsupported 9233965Sjdp operations which return -1 on error. */ 9333965Sjdp 9433965Sjdplong 95130561Sobrien_bfd_n1 (bfd *ignore_abfd ATTRIBUTE_UNUSED) 9633965Sjdp{ 9733965Sjdp bfd_set_error (bfd_error_invalid_operation); 9833965Sjdp return -1; 9933965Sjdp} 10033965Sjdp 10177298Sobrienvoid 102130561Sobrienbfd_void (bfd *ignore ATTRIBUTE_UNUSED) 10333965Sjdp{ 10433965Sjdp} 10533965Sjdp 106218822Sdimlong 107218822Sdim_bfd_norelocs_get_reloc_upper_bound (bfd *abfd ATTRIBUTE_UNUSED, 108218822Sdim asection *sec ATTRIBUTE_UNUSED) 109218822Sdim{ 110218822Sdim return sizeof (arelent *); 111218822Sdim} 112218822Sdim 113218822Sdimlong 114218822Sdim_bfd_norelocs_canonicalize_reloc (bfd *abfd ATTRIBUTE_UNUSED, 115218822Sdim asection *sec ATTRIBUTE_UNUSED, 116218822Sdim arelent **relptr, 117218822Sdim asymbol **symbols ATTRIBUTE_UNUSED) 118218822Sdim{ 119218822Sdim *relptr = NULL; 120218822Sdim return 0; 121218822Sdim} 122218822Sdim 123130561Sobrienbfd_boolean 124130561Sobrien_bfd_nocore_core_file_matches_executable_p 125130561Sobrien (bfd *ignore_core_bfd ATTRIBUTE_UNUSED, 126130561Sobrien bfd *ignore_exec_bfd ATTRIBUTE_UNUSED) 12733965Sjdp{ 12833965Sjdp bfd_set_error (bfd_error_invalid_operation); 129130561Sobrien return FALSE; 13033965Sjdp} 13133965Sjdp 13233965Sjdp/* Routine to handle core_file_failing_command entry point for targets 13333965Sjdp without core file support. */ 13433965Sjdp 13533965Sjdpchar * 136130561Sobrien_bfd_nocore_core_file_failing_command (bfd *ignore_abfd ATTRIBUTE_UNUSED) 13733965Sjdp{ 13833965Sjdp bfd_set_error (bfd_error_invalid_operation); 139130561Sobrien return NULL; 14033965Sjdp} 14133965Sjdp 14233965Sjdp/* Routine to handle core_file_failing_signal entry point for targets 14333965Sjdp without core file support. */ 14433965Sjdp 14533965Sjdpint 146130561Sobrien_bfd_nocore_core_file_failing_signal (bfd *ignore_abfd ATTRIBUTE_UNUSED) 14733965Sjdp{ 14833965Sjdp bfd_set_error (bfd_error_invalid_operation); 14933965Sjdp return 0; 15033965Sjdp} 15133965Sjdp 15233965Sjdpconst bfd_target * 153130561Sobrien_bfd_dummy_target (bfd *ignore_abfd ATTRIBUTE_UNUSED) 15433965Sjdp{ 15533965Sjdp bfd_set_error (bfd_error_wrong_format); 15633965Sjdp return 0; 15733965Sjdp} 15833965Sjdp 15933965Sjdp/* Allocate memory using malloc. */ 16033965Sjdp 161130561Sobrienvoid * 162130561Sobrienbfd_malloc (bfd_size_type size) 16333965Sjdp{ 164130561Sobrien void *ptr; 16533965Sjdp 16689857Sobrien if (size != (size_t) size) 16789857Sobrien { 16889857Sobrien bfd_set_error (bfd_error_no_memory); 16989857Sobrien return NULL; 17089857Sobrien } 17189857Sobrien 172130561Sobrien ptr = malloc ((size_t) size); 17389857Sobrien if (ptr == NULL && (size_t) size != 0) 17433965Sjdp bfd_set_error (bfd_error_no_memory); 17589857Sobrien 17633965Sjdp return ptr; 17733965Sjdp} 17833965Sjdp 179218822Sdim/* Allocate memory using malloc, nmemb * size with overflow checking. */ 180218822Sdim 181218822Sdimvoid * 182218822Sdimbfd_malloc2 (bfd_size_type nmemb, bfd_size_type size) 183218822Sdim{ 184218822Sdim void *ptr; 185218822Sdim 186218822Sdim if ((nmemb | size) >= HALF_BFD_SIZE_TYPE 187218822Sdim && size != 0 188218822Sdim && nmemb > ~(bfd_size_type) 0 / size) 189218822Sdim { 190218822Sdim bfd_set_error (bfd_error_no_memory); 191218822Sdim return NULL; 192218822Sdim } 193218822Sdim 194218822Sdim size *= nmemb; 195218822Sdim 196218822Sdim if (size != (size_t) size) 197218822Sdim { 198218822Sdim bfd_set_error (bfd_error_no_memory); 199218822Sdim return NULL; 200218822Sdim } 201218822Sdim 202218822Sdim ptr = malloc ((size_t) size); 203218822Sdim if (ptr == NULL && (size_t) size != 0) 204218822Sdim bfd_set_error (bfd_error_no_memory); 205218822Sdim 206218822Sdim return ptr; 207218822Sdim} 208218822Sdim 20933965Sjdp/* Reallocate memory using realloc. */ 21033965Sjdp 211130561Sobrienvoid * 212130561Sobrienbfd_realloc (void *ptr, bfd_size_type size) 21333965Sjdp{ 214130561Sobrien void *ret; 21533965Sjdp 21689857Sobrien if (size != (size_t) size) 21789857Sobrien { 21889857Sobrien bfd_set_error (bfd_error_no_memory); 21989857Sobrien return NULL; 22089857Sobrien } 22189857Sobrien 22233965Sjdp if (ptr == NULL) 223130561Sobrien ret = malloc ((size_t) size); 22433965Sjdp else 225130561Sobrien ret = realloc (ptr, (size_t) size); 22633965Sjdp 22789857Sobrien if (ret == NULL && (size_t) size != 0) 22833965Sjdp bfd_set_error (bfd_error_no_memory); 22933965Sjdp 23033965Sjdp return ret; 23133965Sjdp} 23233965Sjdp 233218822Sdim/* Reallocate memory using realloc, nmemb * size with overflow checking. */ 234218822Sdim 235218822Sdimvoid * 236218822Sdimbfd_realloc2 (void *ptr, bfd_size_type nmemb, bfd_size_type size) 237218822Sdim{ 238218822Sdim void *ret; 239218822Sdim 240218822Sdim if ((nmemb | size) >= HALF_BFD_SIZE_TYPE 241218822Sdim && size != 0 242218822Sdim && nmemb > ~(bfd_size_type) 0 / size) 243218822Sdim { 244218822Sdim bfd_set_error (bfd_error_no_memory); 245218822Sdim return NULL; 246218822Sdim } 247218822Sdim 248218822Sdim size *= nmemb; 249218822Sdim 250218822Sdim if (size != (size_t) size) 251218822Sdim { 252218822Sdim bfd_set_error (bfd_error_no_memory); 253218822Sdim return NULL; 254218822Sdim } 255218822Sdim 256218822Sdim if (ptr == NULL) 257218822Sdim ret = malloc ((size_t) size); 258218822Sdim else 259218822Sdim ret = realloc (ptr, (size_t) size); 260218822Sdim 261218822Sdim if (ret == NULL && (size_t) size != 0) 262218822Sdim bfd_set_error (bfd_error_no_memory); 263218822Sdim 264218822Sdim return ret; 265218822Sdim} 266218822Sdim 26733965Sjdp/* Allocate memory using malloc and clear it. */ 26833965Sjdp 269130561Sobrienvoid * 270130561Sobrienbfd_zmalloc (bfd_size_type size) 27133965Sjdp{ 272130561Sobrien void *ptr; 27333965Sjdp 27489857Sobrien if (size != (size_t) size) 27589857Sobrien { 27689857Sobrien bfd_set_error (bfd_error_no_memory); 27789857Sobrien return NULL; 27889857Sobrien } 27933965Sjdp 280130561Sobrien ptr = malloc ((size_t) size); 28189857Sobrien 28289857Sobrien if ((size_t) size != 0) 28333965Sjdp { 28433965Sjdp if (ptr == NULL) 28533965Sjdp bfd_set_error (bfd_error_no_memory); 28633965Sjdp else 28789857Sobrien memset (ptr, 0, (size_t) size); 28833965Sjdp } 28933965Sjdp 29033965Sjdp return ptr; 29133965Sjdp} 292218822Sdim 293218822Sdim/* Allocate memory using malloc (nmemb * size) with overflow checking 294218822Sdim and clear it. */ 295218822Sdim 296218822Sdimvoid * 297218822Sdimbfd_zmalloc2 (bfd_size_type nmemb, bfd_size_type size) 298218822Sdim{ 299218822Sdim void *ptr; 300218822Sdim 301218822Sdim if ((nmemb | size) >= HALF_BFD_SIZE_TYPE 302218822Sdim && size != 0 303218822Sdim && nmemb > ~(bfd_size_type) 0 / size) 304218822Sdim { 305218822Sdim bfd_set_error (bfd_error_no_memory); 306218822Sdim return NULL; 307218822Sdim } 308218822Sdim 309218822Sdim size *= nmemb; 310218822Sdim 311218822Sdim if (size != (size_t) size) 312218822Sdim { 313218822Sdim bfd_set_error (bfd_error_no_memory); 314218822Sdim return NULL; 315218822Sdim } 316218822Sdim 317218822Sdim ptr = malloc ((size_t) size); 318218822Sdim 319218822Sdim if ((size_t) size != 0) 320218822Sdim { 321218822Sdim if (ptr == NULL) 322218822Sdim bfd_set_error (bfd_error_no_memory); 323218822Sdim else 324218822Sdim memset (ptr, 0, (size_t) size); 325218822Sdim } 326218822Sdim 327218822Sdim return ptr; 328218822Sdim} 329218822Sdim 33033965Sjdp/* 33133965SjdpINTERNAL_FUNCTION 33233965Sjdp bfd_write_bigendian_4byte_int 33333965Sjdp 33433965SjdpSYNOPSIS 335130561Sobrien bfd_boolean bfd_write_bigendian_4byte_int (bfd *, unsigned int); 33633965Sjdp 33733965SjdpDESCRIPTION 33833965Sjdp Write a 4 byte integer @var{i} to the output BFD @var{abfd}, in big 33933965Sjdp endian order regardless of what else is going on. This is useful in 34033965Sjdp archives. 34133965Sjdp 34233965Sjdp*/ 343130561Sobrienbfd_boolean 344130561Sobrienbfd_write_bigendian_4byte_int (bfd *abfd, unsigned int i) 34533965Sjdp{ 34633965Sjdp bfd_byte buffer[4]; 34789857Sobrien bfd_putb32 ((bfd_vma) i, buffer); 348130561Sobrien return bfd_bwrite (buffer, (bfd_size_type) 4, abfd) == 4; 34933965Sjdp} 35033965Sjdp 35133965Sjdp 35233965Sjdp/** The do-it-yourself (byte) sex-change kit */ 35333965Sjdp 35433965Sjdp/* The middle letter e.g. get<b>short indicates Big or Little endian 35533965Sjdp target machine. It doesn't matter what the byte order of the host 35633965Sjdp machine is; these routines work for either. */ 35733965Sjdp 35833965Sjdp/* FIXME: Should these take a count argument? 35933965Sjdp Answer (gnu@cygnus.com): No, but perhaps they should be inline 36077298Sobrien functions in swap.h #ifdef __GNUC__. 36133965Sjdp Gprof them later and find out. */ 36233965Sjdp 36333965Sjdp/* 36433965SjdpFUNCTION 36533965Sjdp bfd_put_size 36633965SjdpFUNCTION 36733965Sjdp bfd_get_size 36833965Sjdp 36933965SjdpDESCRIPTION 37033965Sjdp These macros as used for reading and writing raw data in 37133965Sjdp sections; each access (except for bytes) is vectored through 37233965Sjdp the target format of the BFD and mangled accordingly. The 37333965Sjdp mangling performs any necessary endian translations and 37433965Sjdp removes alignment restrictions. Note that types accepted and 37533965Sjdp returned by these macros are identical so they can be swapped 37633965Sjdp around in macros---for example, @file{libaout.h} defines <<GET_WORD>> 37733965Sjdp to either <<bfd_get_32>> or <<bfd_get_64>>. 37833965Sjdp 37933965Sjdp In the put routines, @var{val} must be a <<bfd_vma>>. If we are on a 38033965Sjdp system without prototypes, the caller is responsible for making 38133965Sjdp sure that is true, with a cast if necessary. We don't cast 38233965Sjdp them in the macro definitions because that would prevent <<lint>> 38333965Sjdp or <<gcc -Wall>> from detecting sins such as passing a pointer. 38433965Sjdp To detect calling these with less than a <<bfd_vma>>, use 38533965Sjdp <<gcc -Wconversion>> on a host with 64 bit <<bfd_vma>>'s. 38633965Sjdp 38733965Sjdp. 38833965Sjdp.{* Byte swapping macros for user section data. *} 38933965Sjdp. 39033965Sjdp.#define bfd_put_8(abfd, val, ptr) \ 391130561Sobrien. ((void) (*((unsigned char *) (ptr)) = (val) & 0xff)) 39233965Sjdp.#define bfd_put_signed_8 \ 393130561Sobrien. bfd_put_8 39433965Sjdp.#define bfd_get_8(abfd, ptr) \ 395130561Sobrien. (*(unsigned char *) (ptr) & 0xff) 39633965Sjdp.#define bfd_get_signed_8(abfd, ptr) \ 397130561Sobrien. (((*(unsigned char *) (ptr) & 0xff) ^ 0x80) - 0x80) 39833965Sjdp. 39933965Sjdp.#define bfd_put_16(abfd, val, ptr) \ 400130561Sobrien. BFD_SEND (abfd, bfd_putx16, ((val),(ptr))) 40133965Sjdp.#define bfd_put_signed_16 \ 402130561Sobrien. bfd_put_16 40333965Sjdp.#define bfd_get_16(abfd, ptr) \ 404130561Sobrien. BFD_SEND (abfd, bfd_getx16, (ptr)) 40533965Sjdp.#define bfd_get_signed_16(abfd, ptr) \ 406130561Sobrien. BFD_SEND (abfd, bfd_getx_signed_16, (ptr)) 40733965Sjdp. 40833965Sjdp.#define bfd_put_32(abfd, val, ptr) \ 409130561Sobrien. BFD_SEND (abfd, bfd_putx32, ((val),(ptr))) 41033965Sjdp.#define bfd_put_signed_32 \ 411130561Sobrien. bfd_put_32 41233965Sjdp.#define bfd_get_32(abfd, ptr) \ 413130561Sobrien. BFD_SEND (abfd, bfd_getx32, (ptr)) 41433965Sjdp.#define bfd_get_signed_32(abfd, ptr) \ 415130561Sobrien. BFD_SEND (abfd, bfd_getx_signed_32, (ptr)) 41633965Sjdp. 41733965Sjdp.#define bfd_put_64(abfd, val, ptr) \ 418130561Sobrien. BFD_SEND (abfd, bfd_putx64, ((val), (ptr))) 41933965Sjdp.#define bfd_put_signed_64 \ 420130561Sobrien. bfd_put_64 42133965Sjdp.#define bfd_get_64(abfd, ptr) \ 422130561Sobrien. BFD_SEND (abfd, bfd_getx64, (ptr)) 42333965Sjdp.#define bfd_get_signed_64(abfd, ptr) \ 424130561Sobrien. BFD_SEND (abfd, bfd_getx_signed_64, (ptr)) 42533965Sjdp. 426130561Sobrien.#define bfd_get(bits, abfd, ptr) \ 427130561Sobrien. ((bits) == 8 ? (bfd_vma) bfd_get_8 (abfd, ptr) \ 428130561Sobrien. : (bits) == 16 ? bfd_get_16 (abfd, ptr) \ 429130561Sobrien. : (bits) == 32 ? bfd_get_32 (abfd, ptr) \ 430130561Sobrien. : (bits) == 64 ? bfd_get_64 (abfd, ptr) \ 431130561Sobrien. : (abort (), (bfd_vma) - 1)) 43260484Sobrien. 433130561Sobrien.#define bfd_put(bits, abfd, val, ptr) \ 434130561Sobrien. ((bits) == 8 ? bfd_put_8 (abfd, val, ptr) \ 435130561Sobrien. : (bits) == 16 ? bfd_put_16 (abfd, val, ptr) \ 436130561Sobrien. : (bits) == 32 ? bfd_put_32 (abfd, val, ptr) \ 437130561Sobrien. : (bits) == 64 ? bfd_put_64 (abfd, val, ptr) \ 438130561Sobrien. : (abort (), (void) 0)) 43960484Sobrien. 44077298Sobrien*/ 44133965Sjdp 44233965Sjdp/* 44333965SjdpFUNCTION 44433965Sjdp bfd_h_put_size 44533965Sjdp bfd_h_get_size 44633965Sjdp 44733965SjdpDESCRIPTION 44833965Sjdp These macros have the same function as their <<bfd_get_x>> 44989857Sobrien brethren, except that they are used for removing information 45033965Sjdp for the header records of object files. Believe it or not, 45133965Sjdp some object files keep their header records in big endian 45233965Sjdp order and their data in little endian order. 45333965Sjdp. 45433965Sjdp.{* Byte swapping macros for file header data. *} 45533965Sjdp. 45633965Sjdp.#define bfd_h_put_8(abfd, val, ptr) \ 45789857Sobrien. bfd_put_8 (abfd, val, ptr) 45833965Sjdp.#define bfd_h_put_signed_8(abfd, val, ptr) \ 45989857Sobrien. bfd_put_8 (abfd, val, ptr) 46033965Sjdp.#define bfd_h_get_8(abfd, ptr) \ 46189857Sobrien. bfd_get_8 (abfd, ptr) 46233965Sjdp.#define bfd_h_get_signed_8(abfd, ptr) \ 46389857Sobrien. bfd_get_signed_8 (abfd, ptr) 46433965Sjdp. 46533965Sjdp.#define bfd_h_put_16(abfd, val, ptr) \ 46689857Sobrien. BFD_SEND (abfd, bfd_h_putx16, (val, ptr)) 46733965Sjdp.#define bfd_h_put_signed_16 \ 46889857Sobrien. bfd_h_put_16 46933965Sjdp.#define bfd_h_get_16(abfd, ptr) \ 47089857Sobrien. BFD_SEND (abfd, bfd_h_getx16, (ptr)) 47133965Sjdp.#define bfd_h_get_signed_16(abfd, ptr) \ 47289857Sobrien. BFD_SEND (abfd, bfd_h_getx_signed_16, (ptr)) 47333965Sjdp. 47433965Sjdp.#define bfd_h_put_32(abfd, val, ptr) \ 47589857Sobrien. BFD_SEND (abfd, bfd_h_putx32, (val, ptr)) 47633965Sjdp.#define bfd_h_put_signed_32 \ 47789857Sobrien. bfd_h_put_32 47833965Sjdp.#define bfd_h_get_32(abfd, ptr) \ 47989857Sobrien. BFD_SEND (abfd, bfd_h_getx32, (ptr)) 48033965Sjdp.#define bfd_h_get_signed_32(abfd, ptr) \ 48189857Sobrien. BFD_SEND (abfd, bfd_h_getx_signed_32, (ptr)) 48233965Sjdp. 48333965Sjdp.#define bfd_h_put_64(abfd, val, ptr) \ 48489857Sobrien. BFD_SEND (abfd, bfd_h_putx64, (val, ptr)) 48533965Sjdp.#define bfd_h_put_signed_64 \ 48689857Sobrien. bfd_h_put_64 48733965Sjdp.#define bfd_h_get_64(abfd, ptr) \ 48889857Sobrien. BFD_SEND (abfd, bfd_h_getx64, (ptr)) 48933965Sjdp.#define bfd_h_get_signed_64(abfd, ptr) \ 49089857Sobrien. BFD_SEND (abfd, bfd_h_getx_signed_64, (ptr)) 49133965Sjdp. 492130561Sobrien.{* Aliases for the above, which should eventually go away. *} 49389857Sobrien. 494130561Sobrien.#define H_PUT_64 bfd_h_put_64 495130561Sobrien.#define H_PUT_32 bfd_h_put_32 496130561Sobrien.#define H_PUT_16 bfd_h_put_16 497130561Sobrien.#define H_PUT_8 bfd_h_put_8 498130561Sobrien.#define H_PUT_S64 bfd_h_put_signed_64 499130561Sobrien.#define H_PUT_S32 bfd_h_put_signed_32 500130561Sobrien.#define H_PUT_S16 bfd_h_put_signed_16 501130561Sobrien.#define H_PUT_S8 bfd_h_put_signed_8 502130561Sobrien.#define H_GET_64 bfd_h_get_64 503130561Sobrien.#define H_GET_32 bfd_h_get_32 504130561Sobrien.#define H_GET_16 bfd_h_get_16 505130561Sobrien.#define H_GET_8 bfd_h_get_8 506130561Sobrien.#define H_GET_S64 bfd_h_get_signed_64 507130561Sobrien.#define H_GET_S32 bfd_h_get_signed_32 508130561Sobrien.#define H_GET_S16 bfd_h_get_signed_16 509130561Sobrien.#define H_GET_S8 bfd_h_get_signed_8 51089857Sobrien. 51189857Sobrien.*/ 51233965Sjdp 51333965Sjdp/* Sign extension to bfd_signed_vma. */ 51433965Sjdp#define COERCE16(x) (((bfd_signed_vma) (x) ^ 0x8000) - 0x8000) 515130561Sobrien#define COERCE32(x) (((bfd_signed_vma) (x) ^ 0x80000000) - 0x80000000) 516130561Sobrien#define EIGHT_GAZILLION ((bfd_int64_t) 1 << 63) 51733965Sjdp#define COERCE64(x) \ 518130561Sobrien (((bfd_int64_t) (x) ^ EIGHT_GAZILLION) - EIGHT_GAZILLION) 51933965Sjdp 52033965Sjdpbfd_vma 521130561Sobrienbfd_getb16 (const void *p) 52233965Sjdp{ 523130561Sobrien const bfd_byte *addr = p; 52433965Sjdp return (addr[0] << 8) | addr[1]; 52533965Sjdp} 52633965Sjdp 52733965Sjdpbfd_vma 528130561Sobrienbfd_getl16 (const void *p) 52933965Sjdp{ 530130561Sobrien const bfd_byte *addr = p; 53133965Sjdp return (addr[1] << 8) | addr[0]; 53233965Sjdp} 53333965Sjdp 53433965Sjdpbfd_signed_vma 535130561Sobrienbfd_getb_signed_16 (const void *p) 53633965Sjdp{ 537130561Sobrien const bfd_byte *addr = p; 538130561Sobrien return COERCE16 ((addr[0] << 8) | addr[1]); 53933965Sjdp} 54033965Sjdp 54133965Sjdpbfd_signed_vma 542130561Sobrienbfd_getl_signed_16 (const void *p) 54333965Sjdp{ 544130561Sobrien const bfd_byte *addr = p; 545130561Sobrien return COERCE16 ((addr[1] << 8) | addr[0]); 54633965Sjdp} 54733965Sjdp 54833965Sjdpvoid 549130561Sobrienbfd_putb16 (bfd_vma data, void *p) 55033965Sjdp{ 551130561Sobrien bfd_byte *addr = p; 552130561Sobrien addr[0] = (data >> 8) & 0xff; 553130561Sobrien addr[1] = data & 0xff; 55433965Sjdp} 55533965Sjdp 55633965Sjdpvoid 557130561Sobrienbfd_putl16 (bfd_vma data, void *p) 55833965Sjdp{ 559130561Sobrien bfd_byte *addr = p; 560130561Sobrien addr[0] = data & 0xff; 561130561Sobrien addr[1] = (data >> 8) & 0xff; 56233965Sjdp} 56333965Sjdp 56433965Sjdpbfd_vma 565130561Sobrienbfd_getb32 (const void *p) 56633965Sjdp{ 567130561Sobrien const bfd_byte *addr = p; 56860484Sobrien unsigned long v; 56960484Sobrien 57060484Sobrien v = (unsigned long) addr[0] << 24; 57160484Sobrien v |= (unsigned long) addr[1] << 16; 57260484Sobrien v |= (unsigned long) addr[2] << 8; 57360484Sobrien v |= (unsigned long) addr[3]; 574130561Sobrien return v; 57533965Sjdp} 57633965Sjdp 57733965Sjdpbfd_vma 578130561Sobrienbfd_getl32 (const void *p) 57933965Sjdp{ 580130561Sobrien const bfd_byte *addr = p; 58160484Sobrien unsigned long v; 58260484Sobrien 58360484Sobrien v = (unsigned long) addr[0]; 58460484Sobrien v |= (unsigned long) addr[1] << 8; 58560484Sobrien v |= (unsigned long) addr[2] << 16; 58660484Sobrien v |= (unsigned long) addr[3] << 24; 587130561Sobrien return v; 58833965Sjdp} 58933965Sjdp 59033965Sjdpbfd_signed_vma 591130561Sobrienbfd_getb_signed_32 (const void *p) 59233965Sjdp{ 593130561Sobrien const bfd_byte *addr = p; 59460484Sobrien unsigned long v; 59560484Sobrien 59660484Sobrien v = (unsigned long) addr[0] << 24; 59760484Sobrien v |= (unsigned long) addr[1] << 16; 59860484Sobrien v |= (unsigned long) addr[2] << 8; 59960484Sobrien v |= (unsigned long) addr[3]; 60060484Sobrien return COERCE32 (v); 60133965Sjdp} 60233965Sjdp 60333965Sjdpbfd_signed_vma 604130561Sobrienbfd_getl_signed_32 (const void *p) 60533965Sjdp{ 606130561Sobrien const bfd_byte *addr = p; 60760484Sobrien unsigned long v; 60860484Sobrien 60960484Sobrien v = (unsigned long) addr[0]; 61060484Sobrien v |= (unsigned long) addr[1] << 8; 61160484Sobrien v |= (unsigned long) addr[2] << 16; 61260484Sobrien v |= (unsigned long) addr[3] << 24; 61360484Sobrien return COERCE32 (v); 61433965Sjdp} 61533965Sjdp 616130561Sobrienbfd_uint64_t 617130561Sobrienbfd_getb64 (const void *p ATTRIBUTE_UNUSED) 61833965Sjdp{ 619130561Sobrien#ifdef BFD_HOST_64_BIT 620130561Sobrien const bfd_byte *addr = p; 621130561Sobrien bfd_uint64_t v; 62233965Sjdp 623130561Sobrien v = addr[0]; v <<= 8; 624130561Sobrien v |= addr[1]; v <<= 8; 625130561Sobrien v |= addr[2]; v <<= 8; 626130561Sobrien v |= addr[3]; v <<= 8; 627130561Sobrien v |= addr[4]; v <<= 8; 628130561Sobrien v |= addr[5]; v <<= 8; 629130561Sobrien v |= addr[6]; v <<= 8; 630130561Sobrien v |= addr[7]; 63133965Sjdp 632130561Sobrien return v; 63333965Sjdp#else 63433965Sjdp BFD_FAIL(); 63533965Sjdp return 0; 63633965Sjdp#endif 63733965Sjdp} 63833965Sjdp 639130561Sobrienbfd_uint64_t 640130561Sobrienbfd_getl64 (const void *p ATTRIBUTE_UNUSED) 64133965Sjdp{ 642130561Sobrien#ifdef BFD_HOST_64_BIT 643130561Sobrien const bfd_byte *addr = p; 644130561Sobrien bfd_uint64_t v; 64533965Sjdp 646130561Sobrien v = addr[7]; v <<= 8; 647130561Sobrien v |= addr[6]; v <<= 8; 648130561Sobrien v |= addr[5]; v <<= 8; 649130561Sobrien v |= addr[4]; v <<= 8; 650130561Sobrien v |= addr[3]; v <<= 8; 651130561Sobrien v |= addr[2]; v <<= 8; 652130561Sobrien v |= addr[1]; v <<= 8; 653130561Sobrien v |= addr[0]; 65433965Sjdp 655130561Sobrien return v; 65633965Sjdp#else 65733965Sjdp BFD_FAIL(); 65833965Sjdp return 0; 65933965Sjdp#endif 66033965Sjdp 66133965Sjdp} 66233965Sjdp 663130561Sobrienbfd_int64_t 664130561Sobrienbfd_getb_signed_64 (const void *p ATTRIBUTE_UNUSED) 66533965Sjdp{ 666130561Sobrien#ifdef BFD_HOST_64_BIT 667130561Sobrien const bfd_byte *addr = p; 668130561Sobrien bfd_uint64_t v; 66933965Sjdp 670130561Sobrien v = addr[0]; v <<= 8; 671130561Sobrien v |= addr[1]; v <<= 8; 672130561Sobrien v |= addr[2]; v <<= 8; 673130561Sobrien v |= addr[3]; v <<= 8; 674130561Sobrien v |= addr[4]; v <<= 8; 675130561Sobrien v |= addr[5]; v <<= 8; 676130561Sobrien v |= addr[6]; v <<= 8; 677130561Sobrien v |= addr[7]; 67833965Sjdp 679130561Sobrien return COERCE64 (v); 68033965Sjdp#else 68133965Sjdp BFD_FAIL(); 68233965Sjdp return 0; 68333965Sjdp#endif 68433965Sjdp} 68533965Sjdp 686130561Sobrienbfd_int64_t 687130561Sobrienbfd_getl_signed_64 (const void *p ATTRIBUTE_UNUSED) 68833965Sjdp{ 689130561Sobrien#ifdef BFD_HOST_64_BIT 690130561Sobrien const bfd_byte *addr = p; 691130561Sobrien bfd_uint64_t v; 69233965Sjdp 693130561Sobrien v = addr[7]; v <<= 8; 694130561Sobrien v |= addr[6]; v <<= 8; 695130561Sobrien v |= addr[5]; v <<= 8; 696130561Sobrien v |= addr[4]; v <<= 8; 697130561Sobrien v |= addr[3]; v <<= 8; 698130561Sobrien v |= addr[2]; v <<= 8; 699130561Sobrien v |= addr[1]; v <<= 8; 700130561Sobrien v |= addr[0]; 70133965Sjdp 702130561Sobrien return COERCE64 (v); 70333965Sjdp#else 70433965Sjdp BFD_FAIL(); 70533965Sjdp return 0; 70633965Sjdp#endif 70733965Sjdp} 70833965Sjdp 70933965Sjdpvoid 710130561Sobrienbfd_putb32 (bfd_vma data, void *p) 71133965Sjdp{ 712130561Sobrien bfd_byte *addr = p; 713130561Sobrien addr[0] = (data >> 24) & 0xff; 714130561Sobrien addr[1] = (data >> 16) & 0xff; 715130561Sobrien addr[2] = (data >> 8) & 0xff; 716130561Sobrien addr[3] = data & 0xff; 71733965Sjdp} 71833965Sjdp 71933965Sjdpvoid 720130561Sobrienbfd_putl32 (bfd_vma data, void *p) 72133965Sjdp{ 722130561Sobrien bfd_byte *addr = p; 723130561Sobrien addr[0] = data & 0xff; 724130561Sobrien addr[1] = (data >> 8) & 0xff; 725130561Sobrien addr[2] = (data >> 16) & 0xff; 726130561Sobrien addr[3] = (data >> 24) & 0xff; 72733965Sjdp} 72833965Sjdp 72933965Sjdpvoid 730130561Sobrienbfd_putb64 (bfd_uint64_t data ATTRIBUTE_UNUSED, void *p ATTRIBUTE_UNUSED) 73133965Sjdp{ 732130561Sobrien#ifdef BFD_HOST_64_BIT 733130561Sobrien bfd_byte *addr = p; 734130561Sobrien addr[0] = (data >> (7*8)) & 0xff; 735130561Sobrien addr[1] = (data >> (6*8)) & 0xff; 736130561Sobrien addr[2] = (data >> (5*8)) & 0xff; 737130561Sobrien addr[3] = (data >> (4*8)) & 0xff; 738130561Sobrien addr[4] = (data >> (3*8)) & 0xff; 739130561Sobrien addr[5] = (data >> (2*8)) & 0xff; 740130561Sobrien addr[6] = (data >> (1*8)) & 0xff; 741130561Sobrien addr[7] = (data >> (0*8)) & 0xff; 74233965Sjdp#else 74333965Sjdp BFD_FAIL(); 74433965Sjdp#endif 74533965Sjdp} 74633965Sjdp 74733965Sjdpvoid 748130561Sobrienbfd_putl64 (bfd_uint64_t data ATTRIBUTE_UNUSED, void *p ATTRIBUTE_UNUSED) 74933965Sjdp{ 750130561Sobrien#ifdef BFD_HOST_64_BIT 751130561Sobrien bfd_byte *addr = p; 752130561Sobrien addr[7] = (data >> (7*8)) & 0xff; 753130561Sobrien addr[6] = (data >> (6*8)) & 0xff; 754130561Sobrien addr[5] = (data >> (5*8)) & 0xff; 755130561Sobrien addr[4] = (data >> (4*8)) & 0xff; 756130561Sobrien addr[3] = (data >> (3*8)) & 0xff; 757130561Sobrien addr[2] = (data >> (2*8)) & 0xff; 758130561Sobrien addr[1] = (data >> (1*8)) & 0xff; 759130561Sobrien addr[0] = (data >> (0*8)) & 0xff; 76033965Sjdp#else 76133965Sjdp BFD_FAIL(); 76233965Sjdp#endif 76333965Sjdp} 76477298Sobrien 76577298Sobrienvoid 766130561Sobrienbfd_put_bits (bfd_uint64_t data, void *p, int bits, bfd_boolean big_p) 76777298Sobrien{ 768130561Sobrien bfd_byte *addr = p; 76977298Sobrien int i; 77077298Sobrien int bytes; 77177298Sobrien 77277298Sobrien if (bits % 8 != 0) 77377298Sobrien abort (); 77477298Sobrien 77577298Sobrien bytes = bits / 8; 77677298Sobrien for (i = 0; i < bytes; i++) 77777298Sobrien { 77877298Sobrien int index = big_p ? bytes - i - 1 : i; 77977298Sobrien 780130561Sobrien addr[index] = data & 0xff; 78177298Sobrien data >>= 8; 78277298Sobrien } 78377298Sobrien} 78477298Sobrien 785130561Sobrienbfd_uint64_t 786130561Sobrienbfd_get_bits (const void *p, int bits, bfd_boolean big_p) 78777298Sobrien{ 788130561Sobrien const bfd_byte *addr = p; 789130561Sobrien bfd_uint64_t data; 79077298Sobrien int i; 79177298Sobrien int bytes; 79277298Sobrien 79377298Sobrien if (bits % 8 != 0) 79477298Sobrien abort (); 79577298Sobrien 79677298Sobrien data = 0; 79777298Sobrien bytes = bits / 8; 79877298Sobrien for (i = 0; i < bytes; i++) 79977298Sobrien { 80077298Sobrien int index = big_p ? i : bytes - i - 1; 80177298Sobrien 80277298Sobrien data = (data << 8) | addr[index]; 80377298Sobrien } 80477298Sobrien 80577298Sobrien return data; 80677298Sobrien} 80733965Sjdp 80833965Sjdp/* Default implementation */ 80933965Sjdp 810130561Sobrienbfd_boolean 811130561Sobrien_bfd_generic_get_section_contents (bfd *abfd, 812130561Sobrien sec_ptr section, 813130561Sobrien void *location, 814130561Sobrien file_ptr offset, 815130561Sobrien bfd_size_type count) 81633965Sjdp{ 817218822Sdim bfd_size_type sz; 81860484Sobrien if (count == 0) 819130561Sobrien return TRUE; 82060484Sobrien 821218822Sdim sz = section->rawsize ? section->rawsize : section->size; 822218822Sdim if (offset + count > sz) 82360484Sobrien { 82460484Sobrien bfd_set_error (bfd_error_invalid_operation); 825130561Sobrien return FALSE; 82660484Sobrien } 82760484Sobrien 82860484Sobrien if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0 82989857Sobrien || bfd_bread (location, count, abfd) != count) 830130561Sobrien return FALSE; 83160484Sobrien 832130561Sobrien return TRUE; 83333965Sjdp} 83433965Sjdp 835130561Sobrienbfd_boolean 836130561Sobrien_bfd_generic_get_section_contents_in_window 837130561Sobrien (bfd *abfd ATTRIBUTE_UNUSED, 838130561Sobrien sec_ptr section ATTRIBUTE_UNUSED, 839130561Sobrien bfd_window *w ATTRIBUTE_UNUSED, 840130561Sobrien file_ptr offset ATTRIBUTE_UNUSED, 841130561Sobrien bfd_size_type count ATTRIBUTE_UNUSED) 84233965Sjdp{ 84333965Sjdp#ifdef USE_MMAP 844218822Sdim bfd_size_type sz; 845218822Sdim 84633965Sjdp if (count == 0) 847130561Sobrien return TRUE; 848130561Sobrien if (abfd->xvec->_bfd_get_section_contents 849130561Sobrien != _bfd_generic_get_section_contents) 85033965Sjdp { 85133965Sjdp /* We don't know what changes the bfd's get_section_contents 85233965Sjdp method may have to make. So punt trying to map the file 85333965Sjdp window, and let get_section_contents do its thing. */ 85433965Sjdp /* @@ FIXME : If the internal window has a refcount of 1 and was 85533965Sjdp allocated with malloc instead of mmap, just reuse it. */ 85633965Sjdp bfd_free_window (w); 857130561Sobrien w->i = bfd_zmalloc (sizeof (bfd_window_internal)); 85833965Sjdp if (w->i == NULL) 859130561Sobrien return FALSE; 860130561Sobrien w->i->data = bfd_malloc (count); 86133965Sjdp if (w->i->data == NULL) 86233965Sjdp { 86333965Sjdp free (w->i); 86433965Sjdp w->i = NULL; 865130561Sobrien return FALSE; 86633965Sjdp } 86733965Sjdp w->i->mapped = 0; 86833965Sjdp w->i->refcount = 1; 86933965Sjdp w->size = w->i->size = count; 87033965Sjdp w->data = w->i->data; 87133965Sjdp return bfd_get_section_contents (abfd, section, w->data, offset, count); 87233965Sjdp } 873218822Sdim sz = section->rawsize ? section->rawsize : section->size; 874218822Sdim if (offset + count > sz 875104834Sobrien || ! bfd_get_file_window (abfd, section->filepos + offset, count, w, 876130561Sobrien TRUE)) 877130561Sobrien return FALSE; 878130561Sobrien return TRUE; 87933965Sjdp#else 88033965Sjdp abort (); 88133965Sjdp#endif 88233965Sjdp} 88333965Sjdp 88433965Sjdp/* This generic function can only be used in implementations where creating 88533965Sjdp NEW sections is disallowed. It is useful in patching existing sections 88633965Sjdp in read-write files, though. See other set_section_contents functions 88733965Sjdp to see why it doesn't work for new sections. */ 888130561Sobrienbfd_boolean 889130561Sobrien_bfd_generic_set_section_contents (bfd *abfd, 890130561Sobrien sec_ptr section, 891130561Sobrien const void *location, 892130561Sobrien file_ptr offset, 893130561Sobrien bfd_size_type count) 89433965Sjdp{ 89533965Sjdp if (count == 0) 896130561Sobrien return TRUE; 89733965Sjdp 89889857Sobrien if (bfd_seek (abfd, section->filepos + offset, SEEK_SET) != 0 89989857Sobrien || bfd_bwrite (location, count, abfd) != count) 900130561Sobrien return FALSE; 90133965Sjdp 902130561Sobrien return TRUE; 90333965Sjdp} 90433965Sjdp 90533965Sjdp/* 90633965SjdpINTERNAL_FUNCTION 90733965Sjdp bfd_log2 90833965Sjdp 90933965SjdpSYNOPSIS 91089857Sobrien unsigned int bfd_log2 (bfd_vma x); 91133965Sjdp 91233965SjdpDESCRIPTION 91333965Sjdp Return the log base 2 of the value supplied, rounded up. E.g., an 91489857Sobrien @var{x} of 1025 returns 11. A @var{x} of 0 returns 0. 91533965Sjdp*/ 91633965Sjdp 91760484Sobrienunsigned int 918130561Sobrienbfd_log2 (bfd_vma x) 91933965Sjdp{ 92060484Sobrien unsigned int result = 0; 92160484Sobrien 92260484Sobrien while ((x = (x >> 1)) != 0) 92360484Sobrien ++result; 92433965Sjdp return result; 92533965Sjdp} 92633965Sjdp 927130561Sobrienbfd_boolean 928130561Sobrienbfd_generic_is_local_label_name (bfd *abfd, const char *name) 92933965Sjdp{ 93033965Sjdp char locals_prefix = (bfd_get_symbol_leading_char (abfd) == '_') ? 'L' : '.'; 93133965Sjdp 932130561Sobrien return name[0] == locals_prefix; 93333965Sjdp} 93433965Sjdp 93560484Sobrien/* Can be used from / for bfd_merge_private_bfd_data to check that 93660484Sobrien endianness matches between input and output file. Returns 937130561Sobrien TRUE for a match, otherwise returns FALSE and emits an error. */ 938130561Sobrienbfd_boolean 939130561Sobrien_bfd_generic_verify_endian_match (bfd *ibfd, bfd *obfd) 94060484Sobrien{ 94160484Sobrien if (ibfd->xvec->byteorder != obfd->xvec->byteorder 94277298Sobrien && ibfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN 94360484Sobrien && obfd->xvec->byteorder != BFD_ENDIAN_UNKNOWN) 94460484Sobrien { 94577298Sobrien const char *msg; 94660484Sobrien 94777298Sobrien if (bfd_big_endian (ibfd)) 948218822Sdim msg = _("%B: compiled for a big endian system and target is little endian"); 94977298Sobrien else 950218822Sdim msg = _("%B: compiled for a little endian system and target is big endian"); 95177298Sobrien 952218822Sdim (*_bfd_error_handler) (msg, ibfd); 95377298Sobrien 95460484Sobrien bfd_set_error (bfd_error_wrong_format); 955130561Sobrien return FALSE; 95660484Sobrien } 95760484Sobrien 958130561Sobrien return TRUE; 95960484Sobrien} 96089857Sobrien 96189857Sobrien/* Give a warning at runtime if someone compiles code which calls 96289857Sobrien old routines. */ 96391041Sobrien 96489857Sobrienvoid 965130561Sobrienwarn_deprecated (const char *what, 966130561Sobrien const char *file, 967130561Sobrien int line, 968130561Sobrien const char *func) 96989857Sobrien{ 97089857Sobrien /* Poor man's tracking of functions we've already warned about. */ 97189857Sobrien static size_t mask = 0; 97289857Sobrien 97389857Sobrien if (~(size_t) func & ~mask) 97489857Sobrien { 975130561Sobrien /* Note: separate sentences in order to allow 97691041Sobrien for translation into other languages. */ 97789857Sobrien if (func) 97891041Sobrien fprintf (stderr, _("Deprecated %s called at %s line %d in %s\n"), 97991041Sobrien what, file, line, func); 98089857Sobrien else 98191041Sobrien fprintf (stderr, _("Deprecated %s called\n"), what); 98289857Sobrien mask |= ~(size_t) func; 98389857Sobrien } 98489857Sobrien} 985218822Sdim 986218822Sdim/* Helper function for reading uleb128 encoded data. */ 987218822Sdim 988218822Sdimbfd_vma 989218822Sdimread_unsigned_leb128 (bfd *abfd ATTRIBUTE_UNUSED, 990218822Sdim bfd_byte *buf, 991218822Sdim unsigned int *bytes_read_ptr) 992218822Sdim{ 993218822Sdim bfd_vma result; 994218822Sdim unsigned int num_read; 995218822Sdim unsigned int shift; 996218822Sdim unsigned char byte; 997218822Sdim 998218822Sdim result = 0; 999218822Sdim shift = 0; 1000218822Sdim num_read = 0; 1001218822Sdim do 1002218822Sdim { 1003218822Sdim byte = bfd_get_8 (abfd, buf); 1004218822Sdim buf++; 1005218822Sdim num_read++; 1006218822Sdim result |= (((bfd_vma) byte & 0x7f) << shift); 1007218822Sdim shift += 7; 1008218822Sdim } 1009218822Sdim while (byte & 0x80); 1010218822Sdim *bytes_read_ptr = num_read; 1011218822Sdim return result; 1012218822Sdim} 1013218822Sdim 1014218822Sdim/* Helper function for reading sleb128 encoded data. */ 1015218822Sdim 1016218822Sdimbfd_signed_vma 1017218822Sdimread_signed_leb128 (bfd *abfd ATTRIBUTE_UNUSED, 1018218822Sdim bfd_byte *buf, 1019218822Sdim unsigned int *bytes_read_ptr) 1020218822Sdim{ 1021218822Sdim bfd_vma result; 1022218822Sdim unsigned int shift; 1023218822Sdim unsigned int num_read; 1024218822Sdim unsigned char byte; 1025218822Sdim 1026218822Sdim result = 0; 1027218822Sdim shift = 0; 1028218822Sdim num_read = 0; 1029218822Sdim do 1030218822Sdim { 1031218822Sdim byte = bfd_get_8 (abfd, buf); 1032218822Sdim buf ++; 1033218822Sdim num_read ++; 1034218822Sdim result |= (((bfd_vma) byte & 0x7f) << shift); 1035218822Sdim shift += 7; 1036218822Sdim } 1037218822Sdim while (byte & 0x80); 1038218822Sdim if (shift < 8 * sizeof (result) && (byte & 0x40)) 1039218822Sdim result |= (((bfd_vma) -1) << shift); 1040218822Sdim *bytes_read_ptr = num_read; 1041218822Sdim return result; 1042218822Sdim} 1043218822Sdim 1044218822Sdimbfd_boolean 1045218822Sdim_bfd_generic_find_line (bfd *abfd ATTRIBUTE_UNUSED, 1046218822Sdim asymbol **symbols ATTRIBUTE_UNUSED, 1047218822Sdim asymbol *symbol ATTRIBUTE_UNUSED, 1048218822Sdim const char **filename_ptr ATTRIBUTE_UNUSED, 1049218822Sdim unsigned int *linenumber_ptr ATTRIBUTE_UNUSED) 1050218822Sdim{ 1051218822Sdim return FALSE; 1052218822Sdim} 1053218822Sdim 1054218822Sdimbfd_boolean 1055218822Sdim_bfd_generic_init_private_section_data (bfd *ibfd ATTRIBUTE_UNUSED, 1056218822Sdim asection *isec ATTRIBUTE_UNUSED, 1057218822Sdim bfd *obfd ATTRIBUTE_UNUSED, 1058218822Sdim asection *osec ATTRIBUTE_UNUSED, 1059218822Sdim struct bfd_link_info *link_info ATTRIBUTE_UNUSED) 1060218822Sdim{ 1061218822Sdim return TRUE; 1062218822Sdim} 1063