📄 bfd.h
字号:
/* Used by special functions */ bfd_reloc_continue, /* Unused */ bfd_reloc_notsupported, /* Unsupported relocation size requested. */ bfd_reloc_other, /* The symbol to relocate against was undefined.*/ bfd_reloc_undefined, /* The relocation was performed, but may not be ok - presently generated only when linking i960 coff files with i960 b.out symbols. */ bfd_reloc_dangerous } bfd_reloc_status_type;typedef struct reloc_cache_entry { /* A pointer into the canonical table of pointers */ struct symbol_cache_entry **sym_ptr_ptr; /* offset in section */ rawdata_offset address; /* addend for relocation value */ bfd_vma addend; /* Pointer to how to perform the required relocation */ CONST struct reloc_howto_struct *howto;} arelent;typedef CONST struct reloc_howto_struct { /* The type field has mainly a documetary use - the back end can to what it wants with it, though the normally the back end's external idea of what a reloc number would be would be stored in this field. For example, the a PC relative word relocation in a coff environment would have the type 023 - because that's what the outside world calls a R_PCRWORD reloc. */ unsigned int type; /* The value the final relocation is shifted right by. This drops unwanted data from the relocation. */ unsigned int rightshift; /* The size of the item to be relocated - 0, is one byte, 1 is 2 bytes, 3 is four bytes. A -ve value indicates that the result is to be subtracted from the data*/ int size; /* Now obsolete */ unsigned int bitsize; /* Notes that the relocation is relative to the location in the data section of the addend. The relocation function will subtract from the relocation value the address of the location being relocated. */ boolean pc_relative; /* Now obsolete */ unsigned int bitpos; /* Now obsolete */ boolean absolute; /* Causes the relocation routine to return an error if overflow is detected when relocating. */ boolean complain_on_overflow; /* If this field is non null, then the supplied function is called rather than the normal function. This allows really strange relocation methods to be accomodated (eg, i960 callj instructions). */ bfd_reloc_status_type EXFUN ((*special_function), (bfd *abfd, arelent *reloc_entry, struct symbol_cache_entry *symbol, PTR data, asection *input_section, bfd *output_bfd )); /* The textual name of the relocation type. */ char *name; /* When performing a partial link, some formats must modify the relocations rather than the data - this flag signals this.*/ boolean partial_inplace; /* The src_mask is used to select what parts of the read in data are to be used in the relocation sum. Eg, if this was an 8 bit bit of data which we read and relocated, this would be 0x000000ff. When we have relocs which have an addend, such as sun4 extended relocs, the value in the offset part of a relocating field is garbage so we never use it. In this case the mask would be 0x00000000. */ bfd_word src_mask; /* The dst_mask is what parts of the instruction are replaced into the instruction. In most cases src_mask == dst_mask, except in the above special case, where dst_mask would be 0x000000ff, and src_mask would be 0x00000000. */ bfd_word dst_mask; /* When some formats create PC relative instructions, they leave the value of the pc of the place being relocated in the offset slot of the instruction, so that a PC relative relocation can be made just by adding in an ordinary offset (eg sun3 a.out). Some formats leave the displacement part of an instruction empty (eg m88k bcs), this flag signals the fact.*/ boolean pcrel_offset;} reloc_howto_type;#define HOWTO(C, R,S,B, P, BI, ABS, O, SF, NAME, INPLACE, MASKSRC, MASKDST, PC) \ {(unsigned)C,R,S,B, P, BI, ABS,O,SF,NAME,INPLACE,MASKSRC,MASKDST,PC}#define NEWHOWTO( FUNCTION, NAME,SIZE,REL,IN) HOWTO(0,0,SIZE,0,REL,0,false,false,FUNCTION, NAME,false,0,0,IN)#define HOWTO_PREPARE(relocation, symbol) \ { \ if (symbol != (asymbol *)NULL) { \ if (symbol->section == &bfd_com_section) { \ relocation = 0; \ } \ else { \ relocation = symbol->value; \ } \ } \} typedef unsigned char bfd_byte;typedef struct relent_chain { arelent relent; struct relent_chain *next;} arelent_chain;bfd_reloc_status_typeEXFUN(bfd_perform_relocation , (bfd * abfd, arelent *reloc_entry, PTR data, asection *input_section, bfd *output_bfd));typedef enum bfd_reloc_code_real { /* 16 bits wide, simple reloc */ BFD_RELOC_16, /* 8 bits wide, but used to form an address like 0xffnn */ BFD_RELOC_8_FFnn, /* 8 bits wide, simple */ BFD_RELOC_8, /* 8 bits wide, pc relative */ BFD_RELOC_8_PCREL, /* The type of reloc used to build a contructor table - at the moment probably a 32 bit wide abs address, but the cpu can choose. */ BFD_RELOC_CTOR, /* 32 bits wide, simple reloc */ BFD_RELOC_32, /* 32 bits, PC-relative */ BFD_RELOC_32_PCREL, /* High 22 bits of 32-bit value; simple reloc. */ BFD_RELOC_HI22, /* Low 10 bits. */ BFD_RELOC_LO10, /* Reloc types used for i960/b.out. */ BFD_RELOC_24_PCREL, BFD_RELOC_I960_CALLJ, BFD_RELOC_16_PCREL, /* 32-bit pc-relative, shifted right 2 bits (i.e., 30-bit word displacement, e.g. for SPARC) */ BFD_RELOC_32_PCREL_S2, /* now for the sparc/elf codes */ BFD_RELOC_NONE, /* actually used */ BFD_RELOC_SPARC_WDISP22, BFD_RELOC_SPARC22, BFD_RELOC_SPARC13, BFD_RELOC_SPARC_BASE13, BFD_RELOC_SPARC_GOT10, BFD_RELOC_SPARC_GOT13, BFD_RELOC_SPARC_GOT22, BFD_RELOC_SPARC_PC10, BFD_RELOC_SPARC_PC22, BFD_RELOC_SPARC_WPLT30, BFD_RELOC_SPARC_COPY, BFD_RELOC_SPARC_GLOB_DAT, BFD_RELOC_SPARC_JMP_SLOT, BFD_RELOC_SPARC_RELATIVE, BFD_RELOC_SPARC_UA32, /* this one is a.out specific? */ BFD_RELOC_SPARC_BASE22, /* this must be the highest numeric value */ BFD_RELOC_UNUSED } bfd_reloc_code_real_type;CONST struct reloc_howto_struct *EXFUN(bfd_reloc_type_lookup , (bfd *abfd, bfd_reloc_code_real_type code));typedef struct symbol_cache_entry { /* A pointer to the BFD which owns the symbol. This information is necessary so that a back end can work out what additional (invisible to the application writer) information is carried with the symbol. */ struct _bfd *the_bfd; /* The text of the symbol. The name is left alone, and not copied - the application may not alter it. */ CONST char *name; /* The value of the symbol.*/ symvalue value; /* Attributes of a symbol: */#define BSF_NO_FLAGS 0x00 /* The symbol has local scope; <<static>> in <<C>>. The value is the offset into the section of the data. */#define BSF_LOCAL 0x01 /* The symbol has global scope; initialized data in <<C>>. The value is the offset into the section of the data. */#define BSF_GLOBAL 0x02 /* Obsolete */#define BSF_IMPORT 0x04 /* The symbol has global scope, and is exported. The value is the offset into the section of the data. */#define BSF_EXPORT 0x08 /* The symbol is undefined. <<extern>> in <<C>>. The value has no meaning. */#define BSF_UNDEFINED_OBS 0x10 /* The symbol is common, initialized to zero; default in <<C>>. The value is the size of the object in bytes. */#define BSF_FORT_COMM_OBS 0x20 /* A normal C symbol would be one of: <<BSF_LOCAL>>, <<BSF_FORT_COMM>>, <<BSF_UNDEFINED>> or <<BSF_EXPORT|BSD_GLOBAL>> */ /* The symbol is a debugging record. The value has an arbitary meaning. */#define BSF_DEBUGGING 0x40 /* Used by the linker */#define BSF_KEEP 0x10000#define BSF_KEEP_G 0x80000 /* Unused */#define BSF_WEAK 0x100000#define BSF_CTOR 0x200000 /* This symbol was created to point to a section, e.g. ELF's STT_SECTION symbols. */#define BSF_SECTION_SYM 0x400000 /* The symbol used to be a common symbol, but now it is allocated. */#define BSF_OLD_COMMON 0x800000 /* The default value for common data. */#define BFD_FORT_COMM_DEFAULT_VALUE 0 /* In some files the type of a symbol sometimes alters its location in an output file - ie in coff a <<ISFCN>> symbol which is also <<C_EXT>> symbol appears where it was declared and not at the end of a section. This bit is set by the target BFD part to convey this information. */#define BSF_NOT_AT_END 0x40000 /* Signal that the symbol is the label of constructor section. */#define BSF_CONSTRUCTOR 0x1000000 /* Signal that the symbol is a warning symbol. If the symbol is a warning symbol, then the value field (I know this is tacky) will point to the asymbol which when referenced will cause the warning. */#define BSF_WARNING 0x2000000 /* Signal that the symbol is indirect. The value of the symbol is a pointer to an undefined asymbol which contains the name to use instead. */#define BSF_INDIRECT 0x4000000 /* BSF_FILE marks symbols that contain a file name. This is used for ELF STT_FILE symbols. */#define BSF_FILE 0x08000000 flagword flags; /* A pointer to the section to which this symbol is relative. This will always be non NULL, there are special sections for undefined and absolute symbols */ struct sec *section; /* Back end special data. This is being phased out in favour of making this a union. */ PTR udata; } asymbol;#define get_symtab_upper_bound(abfd) \ BFD_SEND (abfd, _get_symtab_upper_bound, (abfd))#define bfd_canonicalize_symtab(abfd, location) \ BFD_SEND (abfd, _bfd_canonicalize_symtab,\ (abfd, location))boolean EXFUN(bfd_set_symtab , (bfd *, asymbol **, unsigned int ));void EXFUN(bfd_print_symbol_vandf, (PTR file, asymbol *symbol));#define bfd_make_empty_symbol(abfd) \ BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd))#define bfd_make_debug_symbol(abfd,ptr,size) \ BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size))int EXFUN(bfd_decode_symclass, (asymbol *symbol));struct _bfd { /* The filename the application opened the BFD with. */ CONST char *filename; /* A pointer to the target jump table. */ struct bfd_target *xvec; /* To avoid dragging too many header files into every file that includes `<<bfd.h>>', IOSTREAM has been declared as a "char *", and MTIME as a "long". Their correct types, to which they are cast when used, are "FILE *" and "time_t". The iostream is the result of an fopen on the filename. */ char *iostream; /* Is the file being cached */ boolean cacheable; /* Marks whether there was a default target specified when the BFD was opened. This is used to select what matching algorithm to use to chose the back end. */ boolean target_defaulted;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -