URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
[/] [or1k/] [trunk/] [insight/] [bfd/] [doc/] [bfd.info-2] - Rev 1774
Go to most recent revision | Compare with Previous | Blame | View Log
This is bfd.info, produced by makeinfo version 4.0 from bfd.texinfo.START-INFO-DIR-ENTRY* Bfd: (bfd). The Binary File Descriptor library.END-INFO-DIR-ENTRYThis file documents the BFD library.Copyright (C) 1991, 2000 Free Software Foundation, Inc.Permission is granted to copy, distribute and/or modify this documentunder the terms of the GNU Free Documentation License, Version 1.1or any later version published by the Free Software Foundation;with no Invariant Sections, with no Front-Cover Texts, and with noBack-Cover Texts. A copy of the license is included in thesection entitled "GNU Free Documentation License".File: bfd.info, Node: typedef asection, Next: section prototypes, Prev: Section Output, Up: Sectionstypedef asection----------------Here is the section structure:/* This structure is used for a comdat section, as in PE. A comdatsection is associated with a particular symbol. When the linkersees a comdat section, it keeps only one of the sections with agiven name and associated with a given symbol. */struct bfd_comdat_info{/* The name of the symbol associated with a comdat section. */const char *name;/* The local symbol table index of the symbol associated with acomdat section. This is only meaningful to the object file formatspecific code; it is not an index into the list returned bybfd_canonicalize_symtab. */long symbol;};typedef struct sec{/* The name of the section; the name isn't a copy, the pointer isthe same as that passed to bfd_make_section. */const char *name;/* A unique sequence number. */int id;/* Which section is it; 0..nth. */int index;/* The next section in the list belonging to the BFD, or NULL. */struct sec *next;/* The field flags contains attributes of the section. Someflags are read in from the object file, and some aresynthesized from other information. */flagword flags;#define SEC_NO_FLAGS 0x000/* Tells the OS to allocate space for this section when loading.This is clear for a section containing debug information only. */#define SEC_ALLOC 0x001/* Tells the OS to load the section from the file when loading.This is clear for a .bss section. */#define SEC_LOAD 0x002/* The section contains data still to be relocated, so there issome relocation information too. */#define SEC_RELOC 0x004#if 0 /* Obsolete ? */#define SEC_BALIGN 0x008#endif/* A signal to the OS that the section contains read only data. */#define SEC_READONLY 0x010/* The section contains code only. */#define SEC_CODE 0x020/* The section contains data only. */#define SEC_DATA 0x040/* The section will reside in ROM. */#define SEC_ROM 0x080/* The section contains constructor information. This sectiontype is used by the linker to create lists of constructors anddestructors used by `g++'. When a back end sees a symbolwhich should be used in a constructor list, it creates a newsection for the type of name (e.g., `__CTOR_LIST__'), attachesthe symbol to it, and builds a relocation. To build the listsof constructors, all the linker has to do is catenate all thesections called `__CTOR_LIST__' and relocate the datacontained within - exactly the operations it would peform onstandard data. */#define SEC_CONSTRUCTOR 0x100/* The section is a constructor, and should be placed at theend of the text, data, or bss section(?). */#define SEC_CONSTRUCTOR_TEXT 0x1100#define SEC_CONSTRUCTOR_DATA 0x2100#define SEC_CONSTRUCTOR_BSS 0x3100/* The section has contents - a data section could be`SEC_ALLOC' | `SEC_HAS_CONTENTS'; a debug section could be`SEC_HAS_CONTENTS' */#define SEC_HAS_CONTENTS 0x200/* An instruction to the linker to not output the sectioneven if it has information which would normally be written. */#define SEC_NEVER_LOAD 0x400/* The section is a COFF shared library section. This flag isonly for the linker. If this type of section appears inthe input file, the linker must copy it to the output filewithout changing the vma or size. FIXME: Although thiswas originally intended to be general, it really is COFFspecific (and the flag was renamed to indicate this). Itmight be cleaner to have some more general mechanism toallow the back end to control what the linker does withsections. */#define SEC_COFF_SHARED_LIBRARY 0x800/* The section has GOT references. This flag is only for thelinker, and is currently only used by the elf32-hppa back end.It will be set if global offset table references were detectedin this section, which indicate to the linker that the sectioncontains PIC code, and must be handled specially when doing astatic link. */#define SEC_HAS_GOT_REF 0x4000/* The section contains common symbols (symbols may be definedmultiple times, the value of a symbol is the amount ofspace it requires, and the largest symbol value is the oneused). Most targets have exactly one of these (which wetranslate to bfd_com_section_ptr), but ECOFF has two. */#define SEC_IS_COMMON 0x8000/* The section contains only debugging information. Forexample, this is set for ELF .debug and .stab sections.strip tests this flag to see if a section can bediscarded. */#define SEC_DEBUGGING 0x10000/* The contents of this section are held in memory pointed toby the contents field. This is checked by bfd_get_section_contents,and the data is retrieved from memory if appropriate. */#define SEC_IN_MEMORY 0x20000/* The contents of this section are to be excluded by thelinker for executable and shared objects unless thoseobjects are to be further relocated. */#define SEC_EXCLUDE 0x40000/* The contents of this section are to be sorted by thebased on the address specified in the associated symboltable. */#define SEC_SORT_ENTRIES 0x80000/* When linking, duplicate sections of the same name should bediscarded, rather than being combined into a single section asis usually done. This is similar to how common symbols arehandled. See SEC_LINK_DUPLICATES below. */#define SEC_LINK_ONCE 0x100000/* If SEC_LINK_ONCE is set, this bitfield describes how the linkershould handle duplicate sections. */#define SEC_LINK_DUPLICATES 0x600000/* This value for SEC_LINK_DUPLICATES means that duplicatesections with the same name should simply be discarded. */#define SEC_LINK_DUPLICATES_DISCARD 0x0/* This value for SEC_LINK_DUPLICATES means that the linkershould warn if there are any duplicate sections, althoughit should still only link one copy. */#define SEC_LINK_DUPLICATES_ONE_ONLY 0x200000/* This value for SEC_LINK_DUPLICATES means that the linkershould warn if any duplicate sections are a different size. */#define SEC_LINK_DUPLICATES_SAME_SIZE 0x400000/* This value for SEC_LINK_DUPLICATES means that the linkershould warn if any duplicate sections contain differentcontents. */#define SEC_LINK_DUPLICATES_SAME_CONTENTS 0x600000/* This section was created by the linker as part of dynamicrelocation or other arcane processing. It is skipped whengoing through the first-pass output, trusting that someoneelse up the line will take care of it later. */#define SEC_LINKER_CREATED 0x800000/* This section should not be subject to garbage collection. */#define SEC_KEEP 0x1000000/* This section contains "short" data, and should be placed"near" the GP. */#define SEC_SMALL_DATA 0x2000000/* This section contains data which may be shared with otherexecutables or shared objects. */#define SEC_SHARED 0x4000000/* When a section with this flag is being linked, then if the size ofthe input section is less than a page, it should not cross a pageboundary. If the size of the input section is one page or more, itshould be aligned on a page boundary. */#define SEC_BLOCK 0x8000000/* Conditionally link this section; do not link if there are noreferences found to any symbol in the section. */#define SEC_CLINK 0x10000000/* Attempt to merge identical entities in the section.Entity size is given in the entsize field. */#define SEC_MERGE 0x20000000/* If given with SEC_MERGE, entities to merge are zero terminatedstrings where entsize specifies character size instead of fixedsize entries. */#define SEC_STRINGS 0x40000000/* End of section flags. *//* Some internal packed boolean fields. *//* See the vma field. */unsigned int user_set_vma : 1;/* Whether relocations have been processed. */unsigned int reloc_done : 1;/* A mark flag used by some of the linker backends. */unsigned int linker_mark : 1;/* Another mark flag used by some of the linker backends. Set foroutput sections that have a input section. */unsigned int linker_has_input : 1;/* A mark flag used by some linker backends for garbage collection. */unsigned int gc_mark : 1;/* Used by the ELF code to mark sections which have been allocated to segments. */unsigned int segment_mark : 1;/* End of internal packed boolean fields. *//* The virtual memory address of the section - where it will beat run time. The symbols are relocated against this. Theuser_set_vma flag is maintained by bfd; if it's not set, thebackend can assign addresses (for example, in `a.out', wherethe default address for `.data' is dependent on the specifictarget and various flags). */bfd_vma vma;/* The load address of the section - where it would be in arom image; really only used for writing section headerinformation. */bfd_vma lma;/* The size of the section in octets, as it will be output.Contains a value even if the section has no contents (e.g., thesize of `.bss'). This will be filled in after relocation. */bfd_size_type _cooked_size;/* The original size on disk of the section, in octets. Normally thisvalue is the same as the size, but if some relaxing hasbeen done, then this value will be bigger. */bfd_size_type _raw_size;/* If this section is going to be output, then this value is theoffset in *bytes* into the output section of the first byte in theinput section (byte ==> smallest addressable unit on thetarget). In most cases, if this was going to start at the100th octet (8-bit quantity) in the output section, this valuewould be 100. However, if the target byte size is 16 bits(bfd_octets_per_byte is "2"), this value would be 50. */bfd_vma output_offset;/* The output section through which to map on output. */struct sec *output_section;/* The alignment requirement of the section, as an exponent of 2 -e.g., 3 aligns to 2^3 (or 8). */unsigned int alignment_power;/* If an input section, a pointer to a vector of relocationrecords for the data in this section. */struct reloc_cache_entry *relocation;/* If an output section, a pointer to a vector of pointers torelocation records for the data in this section. */struct reloc_cache_entry **orelocation;/* The number of relocation records in one of the above */unsigned reloc_count;/* Information below is back end specific - and not always usedor updated. *//* File position of section data. */file_ptr filepos;/* File position of relocation info. */file_ptr rel_filepos;/* File position of line data. */file_ptr line_filepos;/* Pointer to data for applications. */PTR userdata;/* If the SEC_IN_MEMORY flag is set, this points to the actualcontents. */unsigned char *contents;/* Attached line number information. */alent *lineno;/* Number of line number records. */unsigned int lineno_count;/* Entity size for merging purposes. */unsigned int entsize;/* Optional information about a COMDAT entry; NULL if not COMDAT. */struct bfd_comdat_info *comdat;/* Points to the kept section if this section is a link-once section,and is discarded. */struct sec *kept_section;/* When a section is being output, this value changes as morelinenumbers are written out. */file_ptr moving_line_filepos;/* What the section number is in the target world. */int target_index;PTR used_by_bfd;/* If this is a constructor section then here is a list of therelocations created to relocate items within it. */struct relent_chain *constructor_chain;/* The BFD which owns the section. */bfd *owner;/* A symbol which points at this section only */struct symbol_cache_entry *symbol;struct symbol_cache_entry **symbol_ptr_ptr;struct bfd_link_order *link_order_head;struct bfd_link_order *link_order_tail;} asection ;/* These sections are global, and are managed by BFD. The applicationand target back end are not permitted to change the values inthese sections. New code should use the section_ptr macros ratherthan referring directly to the const sections. The const sectionsmay eventually vanish. */#define BFD_ABS_SECTION_NAME "*ABS*"#define BFD_UND_SECTION_NAME "*UND*"#define BFD_COM_SECTION_NAME "*COM*"#define BFD_IND_SECTION_NAME "*IND*"/* the absolute section */extern const asection bfd_abs_section;#define bfd_abs_section_ptr ((asection *) &bfd_abs_section)#define bfd_is_abs_section(sec) ((sec) == bfd_abs_section_ptr)/* Pointer to the undefined section */extern const asection bfd_und_section;#define bfd_und_section_ptr ((asection *) &bfd_und_section)#define bfd_is_und_section(sec) ((sec) == bfd_und_section_ptr)/* Pointer to the common section */extern const asection bfd_com_section;#define bfd_com_section_ptr ((asection *) &bfd_com_section)/* Pointer to the indirect section */extern const asection bfd_ind_section;#define bfd_ind_section_ptr ((asection *) &bfd_ind_section)#define bfd_is_ind_section(sec) ((sec) == bfd_ind_section_ptr)extern const struct symbol_cache_entry * const bfd_abs_symbol;extern const struct symbol_cache_entry * const bfd_com_symbol;extern const struct symbol_cache_entry * const bfd_und_symbol;extern const struct symbol_cache_entry * const bfd_ind_symbol;#define bfd_get_section_size_before_reloc(section) \((section)->reloc_done ? (abort (), (bfd_size_type) 1) \: (section)->_raw_size)#define bfd_get_section_size_after_reloc(section) \((section)->reloc_done ? (section)->_cooked_size \: (abort (), (bfd_size_type) 1))File: bfd.info, Node: section prototypes, Prev: typedef asection, Up: SectionsSection prototypes------------------These are the functions exported by the section handling part of BFD.`bfd_get_section_by_name'.........................*Synopsis*asection *bfd_get_section_by_name(bfd *abfd, const char *name);*Description*Run through ABFD and return the one of the `asection's whose namematches NAME, otherwise `NULL'. *Note Sections::, for more information.This should only be used in special cases; the normal way to processall sections of a given name is to use `bfd_map_over_sections' and`strcmp' on the name (or better yet, base it on the section flags orsomething else) for each section.`bfd_get_unique_section_name'.............................*Synopsis*char *bfd_get_unique_section_name(bfd *abfd,const char *templat,int *count);*Description*Invent a section name that is unique in ABFD by tacking a dot and adigit suffix onto the original TEMPLAT. If COUNT is non-NULL, then itspecifies the first number tried as a suffix to generate a unique name.The value pointed to by COUNT will be incremented in this case.`bfd_make_section_old_way'..........................*Synopsis*asection *bfd_make_section_old_way(bfd *abfd, const char *name);*Description*Create a new empty section called NAME and attach it to the end of thechain of sections for the BFD ABFD. An attempt to create a section witha name which is already in use returns its pointer without changing thesection chain.It has the funny name since this is the way it used to be before itwas rewritten....Possible errors are:* `bfd_error_invalid_operation' - If output has already started forthis BFD.* `bfd_error_no_memory' - If memory allocation fails.`bfd_make_section_anyway'.........................*Synopsis*asection *bfd_make_section_anyway(bfd *abfd, const char *name);*Description*Create a new empty section called NAME and attach it to the end of thechain of sections for ABFD. Create a new section even if there isalready a section with that name.Return `NULL' and set `bfd_error' on error; possible errors are:* `bfd_error_invalid_operation' - If output has already started forABFD.* `bfd_error_no_memory' - If memory allocation fails.`bfd_make_section'..................*Synopsis*asection *bfd_make_section(bfd *, const char *name);*Description*Like `bfd_make_section_anyway', but return `NULL' (without callingbfd_set_error ()) without changing the section chain if there isalready a section named NAME. If there is an error, return `NULL' andset `bfd_error'.`bfd_set_section_flags'.......................*Synopsis*boolean bfd_set_section_flags(bfd *abfd, asection *sec, flagword flags);*Description*Set the attributes of the section SEC in the BFD ABFD to the valueFLAGS. Return `true' on success, `false' on error. Possible errorreturns are:* `bfd_error_invalid_operation' - The section cannot have one ormore of the attributes requested. For example, a .bss section in`a.out' may not have the `SEC_HAS_CONTENTS' field set.`bfd_map_over_sections'.......................*Synopsis*void bfd_map_over_sections(bfd *abfd,void (*func) (bfd *abfd,asection *sect,PTR obj),PTR obj);*Description*Call the provided function FUNC for each section attached to the BFDABFD, passing OBJ as an argument. The function will be called as if byfunc(abfd, the_section, obj);This is the prefered method for iterating over sections; analternative would be to use a loop:section *p;for (p = abfd->sections; p != NULL; p = p->next)func(abfd, p, ...)`bfd_set_section_size'......................*Synopsis*boolean bfd_set_section_size(bfd *abfd, asection *sec, bfd_size_type val);*Description*Set SEC to the size VAL. If the operation is ok, then `true' isreturned, else `false'.Possible error returns:* `bfd_error_invalid_operation' - Writing has started to the BFD, sosetting the size is invalid.`bfd_set_section_contents'..........................*Synopsis*boolean bfd_set_section_contents(bfd *abfd,asection *section,PTR data,file_ptr offset,bfd_size_type count);*Description*Sets the contents of the section SECTION in BFD ABFD to the datastarting in memory at DATA. The data is written to the output sectionstarting at offset OFFSET for COUNT octets.Normally `true' is returned, else `false'. Possible error returnsare:* `bfd_error_no_contents' - The output section does not have the`SEC_HAS_CONTENTS' attribute, so nothing can be written to it.* and some more tooThis routine is front end to the back end function`_bfd_set_section_contents'.`bfd_get_section_contents'..........................*Synopsis*boolean bfd_get_section_contents(bfd *abfd, asection *section, PTR location,file_ptr offset, bfd_size_type count);*Description*Read data from SECTION in BFD ABFD into memory starting at LOCATION.The data is read at an offset of OFFSET from the start of the inputsection, and is read for COUNT bytes.If the contents of a constructor with the `SEC_CONSTRUCTOR' flag setare requested or if the section does not have the `SEC_HAS_CONTENTS'flag set, then the LOCATION is filled with zeroes. If no errors occur,`true' is returned, else `false'.`bfd_copy_private_section_data'...............................*Synopsis*boolean bfd_copy_private_section_data(bfd *ibfd, asection *isec, bfd *obfd, asection *osec);*Description*Copy private section information from ISEC in the BFD IBFD to thesection OSEC in the BFD OBFD. Return `true' on success, `false' onerror. Possible error returns are:* `bfd_error_no_memory' - Not enough memory exists to create privatedata for OSEC.#define bfd_copy_private_section_data(ibfd, isection, obfd, osection) \BFD_SEND (obfd, _bfd_copy_private_section_data, \(ibfd, isection, obfd, osection))`_bfd_strip_section_from_output'................................*Synopsis*void _bfd_strip_section_from_output(struct bfd_link_info *info, asection *section);*Description*Remove SECTION from the output. If the output section becomes empty,remove it from the output bfd. INFO may be NULL; if it is not, it isused to decide whether the output section is empty.File: bfd.info, Node: Symbols, Next: Archives, Prev: Sections, Up: BFD front endSymbols=======BFD tries to maintain as much symbol information as it can when itmoves information from file to file. BFD passes information toapplications though the `asymbol' structure. When the applicationrequests the symbol table, BFD reads the table in the native form andtranslates parts of it into the internal format. To maintain more thanthe information passed to applications, some targets keep someinformation "behind the scenes" in a structure only the particular backend knows about. For example, the coff back end keeps the originalsymbol table structure as well as the canonical structure when a BFD isread in. On output, the coff back end can reconstruct the output symboltable so that no information is lost, even information unique to coffwhich BFD doesn't know or understand. If a coff symbol table were read,but were written through an a.out back end, all the coff specificinformation would be lost. The symbol table of a BFD is not necessarilyread in until a canonicalize request is made. Then the BFD back endfills in a table provided by the application with pointers to thecanonical information. To output symbols, the application provides BFDwith a table of pointers to pointers to `asymbol's. This allowsapplications like the linker to output a symbol as it was read, sincethe "behind the scenes" information will be still available.* Menu:* Reading Symbols::* Writing Symbols::* Mini Symbols::* typedef asymbol::* symbol handling functions::File: bfd.info, Node: Reading Symbols, Next: Writing Symbols, Prev: Symbols, Up: SymbolsReading symbols---------------There are two stages to reading a symbol table from a BFD:allocating storage, and the actual reading process. This is an excerptfrom an application which reads the symbol table:long storage_needed;asymbol **symbol_table;long number_of_symbols;long i;storage_needed = bfd_get_symtab_upper_bound (abfd);if (storage_needed < 0)FAILif (storage_needed == 0) {return ;}symbol_table = (asymbol **) xmalloc (storage_needed);...number_of_symbols =bfd_canonicalize_symtab (abfd, symbol_table);if (number_of_symbols < 0)FAILfor (i = 0; i < number_of_symbols; i++) {process_symbol (symbol_table[i]);}All storage for the symbols themselves is in an objalloc connectedto the BFD; it is freed when the BFD is closed.File: bfd.info, Node: Writing Symbols, Next: Mini Symbols, Prev: Reading Symbols, Up: SymbolsWriting symbols---------------Writing of a symbol table is automatic when a BFD open for writingis closed. The application attaches a vector of pointers to pointers tosymbols to the BFD being written, and fills in the symbol count. Theclose and cleanup code reads through the table provided and performsall the necessary operations. The BFD output code must always beprovided with an "owned" symbol: one which has come from another BFD,or one which has been created using `bfd_make_empty_symbol'. Here is anexample showing the creation of a symbol table with only one element:#include "bfd.h"main(){bfd *abfd;asymbol *ptrs[2];asymbol *new;abfd = bfd_openw("foo","a.out-sunos-big");bfd_set_format(abfd, bfd_object);new = bfd_make_empty_symbol(abfd);new->name = "dummy_symbol";new->section = bfd_make_section_old_way(abfd, ".text");new->flags = BSF_GLOBAL;new->value = 0x12345;ptrs[0] = new;ptrs[1] = (asymbol *)0;bfd_set_symtab(abfd, ptrs, 1);bfd_close(abfd);}./makesymnm foo00012345 A dummy_symbolMany formats cannot represent arbitary symbol information; forinstance, the `a.out' object format does not allow an arbitary numberof sections. A symbol pointing to a section which is not one of`.text', `.data' or `.bss' cannot be described.File: bfd.info, Node: Mini Symbols, Next: typedef asymbol, Prev: Writing Symbols, Up: SymbolsMini Symbols------------Mini symbols provide read-only access to the symbol table. They useless memory space, but require more time to access. They can be usefulfor tools like nm or objdump, which may have to handle symbol tables ofextremely large executables.The `bfd_read_minisymbols' function will read the symbols intomemory in an internal form. It will return a `void *' pointer to ablock of memory, a symbol count, and the size of each symbol. Thepointer is allocated using `malloc', and should be freed by the callerwhen it is no longer needed.The function `bfd_minisymbol_to_symbol' will take a pointer to aminisymbol, and a pointer to a structure returned by`bfd_make_empty_symbol', and return a `asymbol' structure. The returnvalue may or may not be the same as the value from`bfd_make_empty_symbol' which was passed in.File: bfd.info, Node: typedef asymbol, Next: symbol handling functions, Prev: Mini Symbols, Up: Symbolstypedef asymbol---------------An `asymbol' has the form:typedef struct symbol_cache_entry{/* A pointer to the BFD which owns the symbol. This informationis necessary so that a back end can work out what additionalinformation (invisible to the application writer) is carriedwith the symbol.This field is *almost* redundant, since you can use section->ownerinstead, except that some symbols point to the global sectionsbfd_{abs,com,und}_section. This could be fixed by makingthese globals be per-bfd (or per-target-flavor). FIXME. */struct _bfd *the_bfd; /* Use bfd_asymbol_bfd(sym) to access this field. *//* The text of the symbol. The name is left alone, and not copied; theapplication may not alter it. */CONST char *name;/* The value of the symbol. This really should be a union of anumeric value with a pointer, since some flags indicate thata pointer to another symbol is stored here. */symvalue value;/* Attributes of a symbol: */#define BSF_NO_FLAGS 0x00/* The symbol has local scope; `static' in `C'. The valueis the offset into the section of the data. */#define BSF_LOCAL 0x01/* The symbol has global scope; initialized data in `C'. Thevalue is the offset into the section of the data. */#define BSF_GLOBAL 0x02/* The symbol has global scope and is exported. The value isthe offset into the section of the data. */#define BSF_EXPORT BSF_GLOBAL /* no real difference *//* A normal C symbol would be one of:`BSF_LOCAL', `BSF_FORT_COMM', `BSF_UNDEFINED' or`BSF_GLOBAL' *//* The symbol is a debugging record. The value has an arbitarymeaning, unless BSF_DEBUGGING_RELOC is also set. */#define BSF_DEBUGGING 0x08/* The symbol denotes a function entry point. Used in ELF,perhaps others someday. */#define BSF_FUNCTION 0x10/* Used by the linker. */#define BSF_KEEP 0x20#define BSF_KEEP_G 0x40/* A weak global symbol, overridable without warnings bya regular global symbol of the same name. */#define BSF_WEAK 0x80/* This symbol was created to point to a section, e.g. ELF'sSTT_SECTION symbols. */#define BSF_SECTION_SYM 0x100/* The symbol used to be a common symbol, but now it isallocated. */#define BSF_OLD_COMMON 0x200/* The default value for common data. */#define BFD_FORT_COMM_DEFAULT_VALUE 0/* In some files the type of a symbol sometimes alters itslocation in an output file - ie in coff a `ISFCN' symbolwhich is also `C_EXT' symbol appears where it wasdeclared and not at the end of a section. This bit is setby the target BFD part to convey this information. */#define BSF_NOT_AT_END 0x400/* Signal that the symbol is the label of constructor section. */#define BSF_CONSTRUCTOR 0x800/* Signal that the symbol is a warning symbol. The name is awarning. The name of the next symbol is the one to warn about;if a reference is made to a symbol with the same name as the nextsymbol, a warning is issued by the linker. */#define BSF_WARNING 0x1000/* Signal that the symbol is indirect. This symbol is an indirectpointer to the symbol with the same name as the next symbol. */#define BSF_INDIRECT 0x2000/* BSF_FILE marks symbols that contain a file name. This is usedfor ELF STT_FILE symbols. */#define BSF_FILE 0x4000/* Symbol is from dynamic linking information. */#define BSF_DYNAMIC 0x8000/* The symbol denotes a data object. Used in ELF, and perhapsothers someday. */#define BSF_OBJECT 0x10000/* This symbol is a debugging symbol. The value is the offsetinto the section of the data. BSF_DEBUGGING should be setas well. */#define BSF_DEBUGGING_RELOC 0x20000flagword flags;/* A pointer to the section to which this symbol isrelative. This will always be non NULL, there are specialsections for undefined and absolute symbols. */struct sec *section;/* Back end special data. */union{PTR p;bfd_vma i;} udata;} asymbol;File: bfd.info, Node: symbol handling functions, Prev: typedef asymbol, Up: SymbolsSymbol handling functions-------------------------`bfd_get_symtab_upper_bound'............................*Description*Return the number of bytes required to store a vector of pointers to`asymbols' for all the symbols in the BFD ABFD, including a terminalNULL pointer. If there are no symbols in the BFD, then return 0. If anerror occurs, return -1.#define bfd_get_symtab_upper_bound(abfd) \BFD_SEND (abfd, _bfd_get_symtab_upper_bound, (abfd))`bfd_is_local_label'....................*Synopsis*boolean bfd_is_local_label(bfd *abfd, asymbol *sym);*Description*Return true if the given symbol SYM in the BFD ABFD is a compilergenerated local label, else return false.`bfd_is_local_label_name'.........................*Synopsis*boolean bfd_is_local_label_name(bfd *abfd, const char *name);*Description*Return true if a symbol with the name NAME in the BFD ABFD is acompiler generated local label, else return false. This just checkswhether the name has the form of a local label.#define bfd_is_local_label_name(abfd, name) \BFD_SEND (abfd, _bfd_is_local_label_name, (abfd, name))`bfd_canonicalize_symtab'.........................*Description*Read the symbols from the BFD ABFD, and fills in the vector LOCATIONwith pointers to the symbols and a trailing NULL. Return the actualnumber of symbol pointers, not including the NULL.#define bfd_canonicalize_symtab(abfd, location) \BFD_SEND (abfd, _bfd_canonicalize_symtab,\(abfd, location))`bfd_set_symtab'................*Synopsis*boolean bfd_set_symtab (bfd *abfd, asymbol **location, unsigned int count);*Description*Arrange that when the output BFD ABFD is closed, the table LOCATION ofCOUNT pointers to symbols will be written.`bfd_print_symbol_vandf'........................*Synopsis*void bfd_print_symbol_vandf(PTR file, asymbol *symbol);*Description*Print the value and flags of the SYMBOL supplied to the stream FILE.`bfd_make_empty_symbol'.......................*Description*Create a new `asymbol' structure for the BFD ABFD and return a pointerto it.This routine is necessary because each back end has privateinformation surrounding the `asymbol'. Building your own `asymbol' andpointing to it will not create the private information, and will causeproblems later on.#define bfd_make_empty_symbol(abfd) \BFD_SEND (abfd, _bfd_make_empty_symbol, (abfd))`bfd_make_debug_symbol'.......................*Description*Create a new `asymbol' structure for the BFD ABFD, to be used as adebugging symbol. Further details of its use have yet to be worked out.#define bfd_make_debug_symbol(abfd,ptr,size) \BFD_SEND (abfd, _bfd_make_debug_symbol, (abfd, ptr, size))`bfd_decode_symclass'.....................*Description*Return a character corresponding to the symbol class of SYMBOL, or '?'for an unknown class.*Synopsis*int bfd_decode_symclass(asymbol *symbol);`bfd_is_undefined_symclass'...........................*Description*Returns non-zero if the class symbol returned by bfd_decode_symclassrepresents an undefined symbol. Returns zero otherwise.*Synopsis*boolean bfd_is_undefined_symclass (int symclass);`bfd_symbol_info'.................*Description*Fill in the basic info about symbol that nm needs. Additional info maybe added by the back-ends after calling this function.*Synopsis*void bfd_symbol_info(asymbol *symbol, symbol_info *ret);`bfd_copy_private_symbol_data'..............................*Synopsis*boolean bfd_copy_private_symbol_data(bfd *ibfd, asymbol *isym, bfd *obfd, asymbol *osym);*Description*Copy private symbol information from ISYM in the BFD IBFD to the symbolOSYM in the BFD OBFD. Return `true' on success, `false' on error.Possible error returns are:* `bfd_error_no_memory' - Not enough memory exists to create privatedata for OSEC.#define bfd_copy_private_symbol_data(ibfd, isymbol, obfd, osymbol) \BFD_SEND (obfd, _bfd_copy_private_symbol_data, \(ibfd, isymbol, obfd, osymbol))File: bfd.info, Node: Archives, Next: Formats, Prev: Symbols, Up: BFD front endArchives========*Description*An archive (or library) is just another BFD. It has a symbol table,although there's not much a user program will do with it.The big difference between an archive BFD and an ordinary BFD isthat the archive doesn't have sections. Instead it has a chain of BFDsthat are considered its contents. These BFDs can be manipulated likeany other. The BFDs contained in an archive opened for reading willall be opened for reading. You may put either input or output BFDsinto an archive opened for output; they will be handled correctly whenthe archive is closed.Use `bfd_openr_next_archived_file' to step through the contents ofan archive opened for input. You don't have to read the entire archiveif you don't want to! Read it until you find what you want.Archive contents of output BFDs are chained through the `next'pointer in a BFD. The first one is findable through the `archive_head'slot of the archive. Set it with `bfd_set_archive_head' (q.v.). Agiven BFD may be in only one open output archive at a time.As expected, the BFD archive code is more general than the archivecode of any given environment. BFD archives may contain files ofdifferent formats (e.g., a.out and coff) and even differentarchitectures. You may even place archives recursively into archives!This can cause unexpected confusion, since some archive formats aremore expressive than others. For instance, Intel COFF archives canpreserve long filenames; SunOS a.out archives cannot. If you move afile from the first to the second format and back again, the filenamemay be truncated. Likewise, different a.out environments have differentconventions as to how they truncate filenames, whether they preservedirectory names in filenames, etc. When interoperating with nativetools, be sure your files are homogeneous.Beware: most of these formats do not react well to the presence ofspaces in filenames. We do the best we can, but can't always handlethis case due to restrictions in the format of archives. Many Unixutilities are braindead in regards to spaces and such in filenamesanyway, so this shouldn't be much of a restriction.Archives are supported in BFD in `archive.c'.`bfd_get_next_mapent'.....................*Synopsis*symindex bfd_get_next_mapent(bfd *abfd, symindex previous, carsym **sym);*Description*Step through archive ABFD's symbol table (if it has one). Successivelyupdate SYM with the next symbol's information, returning that symbol's(internal) index into the symbol table.Supply `BFD_NO_MORE_SYMBOLS' as the PREVIOUS entry to get the firstone; returns `BFD_NO_MORE_SYMBOLS' when you've already got the last one.A `carsym' is a canonical archive symbol. The only user-visibleelement is its name, a null-terminated string.`bfd_set_archive_head'......................*Synopsis*boolean bfd_set_archive_head(bfd *output, bfd *new_head);*Description*Set the head of the chain of BFDs contained in the archive OUTPUT toNEW_HEAD.`bfd_openr_next_archived_file'..............................*Synopsis*bfd *bfd_openr_next_archived_file(bfd *archive, bfd *previous);*Description*Provided a BFD, ARCHIVE, containing an archive and NULL, open an inputBFD on the first contained element and returns that. Subsequent callsshould pass the archive and the previous return value to return acreated BFD to the next contained element. NULL is returned when thereare no more.File: bfd.info, Node: Formats, Next: Relocations, Prev: Archives, Up: BFD front endFile formats============A format is a BFD concept of high level file contents type. Theformats supported by BFD are:* `bfd_object'The BFD may contain data, symbols, relocations and debug info.* `bfd_archive'The BFD contains other BFDs and an optional index.* `bfd_core'The BFD contains the result of an executable core dump.`bfd_check_format'..................*Synopsis*boolean bfd_check_format(bfd *abfd, bfd_format format);*Description*Verify if the file attached to the BFD ABFD is compatible with theformat FORMAT (i.e., one of `bfd_object', `bfd_archive' or `bfd_core').If the BFD has been set to a specific target before the call, onlythe named target and format combination is checked. If the target hasnot been set, or has been set to `default', then all the known targetbackends is interrogated to determine a match. If the default targetmatches, it is used. If not, exactly one target must recognize thefile, or an error results.The function returns `true' on success, otherwise `false' with oneof the following error codes:* `bfd_error_invalid_operation' - if `format' is not one of`bfd_object', `bfd_archive' or `bfd_core'.* `bfd_error_system_call' - if an error occured during a read - evensome file mismatches can cause bfd_error_system_calls.* `file_not_recognised' - none of the backends recognised the fileformat.* `bfd_error_file_ambiguously_recognized' - more than one backendrecognised the file format.`bfd_check_format_matches'..........................*Synopsis*boolean bfd_check_format_matches(bfd *abfd, bfd_format format, char ***matching);*Description*Like `bfd_check_format', except when it returns false with `bfd_errno'set to `bfd_error_file_ambiguously_recognized'. In that case, ifMATCHING is not NULL, it will be filled in with a NULL-terminated listof the names of the formats that matched, allocated with `malloc'.Then the user may choose a format and try again.When done with the list that MATCHING points to, the caller shouldfree it.`bfd_set_format'................*Synopsis*boolean bfd_set_format(bfd *abfd, bfd_format format);*Description*This function sets the file format of the BFD ABFD to the formatFORMAT. If the target set in the BFD does not support the formatrequested, the format is invalid, or the BFD is not open for writing,then an error occurs.`bfd_format_string'...................*Synopsis*CONST char *bfd_format_string(bfd_format format);*Description*Return a pointer to a const string `invalid', `object', `archive',`core', or `unknown', depending upon the value of FORMAT.File: bfd.info, Node: Relocations, Next: Core Files, Prev: Formats, Up: BFD front endRelocations===========BFD maintains relocations in much the same way it maintains symbols:they are left alone until required, then read in en-masse andtranslated into an internal form. A common routine`bfd_perform_relocation' acts upon the canonical form to do the fixup.Relocations are maintained on a per section basis, while symbols aremaintained on a per BFD basis.All that a back end has to do to fit the BFD interface is to createa `struct reloc_cache_entry' for each relocation in a particularsection, and fill in the right bits of the structures.* Menu:* typedef arelent::* howto manager::
Go to most recent revision | Compare with Previous | Blame | View Log
