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

Untitled Document

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

Each flavour of coff supported in BFD has its own header file describing the external layout of the structures. There is also an internal description of the coff layout, in `coff/internal.h'. A major function of the coff backend is swapping the bytes and twiddling the bits to translate the external form of the structures into the normal internal form. This is all performed in the bfd_swap_thing_direction routines. Some elements are different sizes between different versions of coff; it is the duty of the coff version specific include file to override the definitions of various packing routines in `coffcode.h'. E.g., the size of line number entry in coff is sometimes 16 bits, and sometimes 32 bits. #defineing PUT_LNSZ_LNNO and GET_LNSZ_LNNO will select the correct one. No doubt, some day someone will find a version of coff which has a varying field size not catered to at the moment. To port BFD, that person will have to add more #defines. Three of the bit twiddling routines are exported to gdb; coff_swap_aux_in, coff_swap_sym_in and coff_swap_lineno_in. GDB reads the symbol table on its own, but uses BFD to fix things up. More of the bit twiddlers are exported for gas; coff_swap_aux_out, coff_swap_sym_out, coff_swap_lineno_out, coff_swap_reloc_out, coff_swap_filehdr_out, coff_swap_aouthdr_out, coff_swap_scnhdr_out. Gas currently keeps track of all the symbol table and reloc drudgery itself, thereby saving the internal BFD overhead, but uses BFD to swap things on the way out, making cross ports much safer. Doing so also allows BFD (and thus the linker) to use the same header files as gas, which makes one avenue to disaster disappear.

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