www.delorie.com/gnu/docs/binutils/bfd_153.html   search  
 
Buy GNU books!


Untitled Document

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2.16.0.3 bfd_get_size

Description
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--for example, `libaout.h' defines GET_WORD to either bfd_get_32 or bfd_get_64.

In the put routines, val must be a bfd_vma. 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't cast them in the macro definitions because that would prevent lint or gcc -Wall from detecting sins such as passing a pointer. To detect calling these with less than a bfd_vma, use gcc -Wconversion on a host with 64 bit bfd_vma's.
 
/* Byte swapping macros for user section data.  */

#define bfd_put_8(abfd, val, ptr) \
                ((void) (*((unsigned char *) (ptr)) = (unsigned char) (val)))
#define bfd_put_signed_8 \
               bfd_put_8
#define bfd_get_8(abfd, ptr) \
                (*(unsigned char *) (ptr) & 0xff)
#define bfd_get_signed_8(abfd, ptr) \
               (((*(unsigned char *) (ptr) & 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))


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2003   by The Free Software Foundation     Updated Jun 2003