URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
[/] [or1k/] [trunk/] [insight/] [bfd/] [doc/] [bfd.info-5] - 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: File Caching, Next: Linker Functions, Prev: Internal, Up: BFD front endFile caching============The file caching mechanism is embedded within BFD and allows theapplication to open as many BFDs as it wants without regard to theunderlying operating system's file descriptor limit (often as low as 20open files). The module in `cache.c' maintains a least recently usedlist of `BFD_CACHE_MAX_OPEN' files, and exports the name`bfd_cache_lookup', which runs around and makes sure that the requiredBFD is open. If not, then it chooses a file to close, closes it andopens the one wanted, returning its file handle.`BFD_CACHE_MAX_OPEN macro'..........................*Description*The maximum number of files which the cache will keep open at one time.#define BFD_CACHE_MAX_OPEN 10`bfd_last_cache'................*Synopsis*extern bfd *bfd_last_cache;*Description*Zero, or a pointer to the topmost BFD on the chain. This is used bythe `bfd_cache_lookup' macro in `libbfd.h' to determine when it canavoid a function call.`bfd_cache_lookup'..................*Description*Check to see if the required BFD is the same as the last one looked up.If so, then it can use the stream in the BFD with impunity, since itcan't have changed since the last lookup; otherwise, it has to performthe complicated lookup function.#define bfd_cache_lookup(x) \((x)==bfd_last_cache? \(FILE*) (bfd_last_cache->iostream): \bfd_cache_lookup_worker(x))`bfd_cache_init'................*Synopsis*boolean bfd_cache_init (bfd *abfd);*Description*Add a newly opened BFD to the cache.`bfd_cache_close'.................*Synopsis*boolean bfd_cache_close (bfd *abfd);*Description*Remove the BFD ABFD from the cache. If the attached file is open, thenclose it too.*Returns*`false' is returned if closing the file fails, `true' is returned ifall is well.`bfd_open_file'...............*Synopsis*FILE* bfd_open_file(bfd *abfd);*Description*Call the OS to open a file for ABFD. Return the `FILE *' (possibly`NULL') that results from this operation. Set up the BFD so thatfuture accesses know the file is open. If the `FILE *' returned is`NULL', then it won't have been put in the cache, so it won't have tobe removed from it.`bfd_cache_lookup_worker'.........................*Synopsis*FILE *bfd_cache_lookup_worker(bfd *abfd);*Description*Called when the macro `bfd_cache_lookup' fails to find a quick answer.Find a file descriptor for ABFD. If necessary, it open it. If thereare already more than `BFD_CACHE_MAX_OPEN' files open, it tries toclose one first, to avoid running out of file descriptors.File: bfd.info, Node: Linker Functions, Next: Hash Tables, Prev: File Caching, Up: BFD front endLinker Functions================The linker uses three special entry points in the BFD target vector.It is not necessary to write special routines for these entry pointswhen creating a new BFD back end, since generic versions are provided.However, writing them can speed up linking and make it usesignificantly less runtime memory.The first routine creates a hash table used by the other routines.The second routine adds the symbols from an object file to the hashtable. The third routine takes all the object files and links themtogether to create the output file. These routines are designed sothat the linker proper does not need to know anything about the symbolsin the object files that it is linking. The linker merely arranges thesections as directed by the linker script and lets BFD handle thedetails of symbols and relocs.The second routine and third routines are passed a pointer to a`struct bfd_link_info' structure (defined in `bfdlink.h') which holdsinformation relevant to the link, including the linker hash table(which was created by the first routine) and a set of callbackfunctions to the linker proper.The generic linker routines are in `linker.c', and use the headerfile `genlink.h'. As of this writing, the only back ends which haveimplemented versions of these routines are a.out (in `aoutx.h') andECOFF (in `ecoff.c'). The a.out routines are used as examplesthroughout this section.* Menu:* Creating a Linker Hash Table::* Adding Symbols to the Hash Table::* Performing the Final Link::File: bfd.info, Node: Creating a Linker Hash Table, Next: Adding Symbols to the Hash Table, Prev: Linker Functions, Up: Linker FunctionsCreating a linker hash table----------------------------The linker routines must create a hash table, which must be derivedfrom `struct bfd_link_hash_table' described in `bfdlink.c'. *Note HashTables::, for information on how to create a derived hash table. Thisentry point is called using the target vector of the linker output file.The `_bfd_link_hash_table_create' entry point must allocate andinitialize an instance of the desired hash table. If the back end doesnot require any additional information to be stored with the entries inthe hash table, the entry point may simply create a `structbfd_link_hash_table'. Most likely, however, some additionalinformation will be needed.For example, with each entry in the hash table the a.out linkerkeeps the index the symbol has in the final output file (this indexnumber is used so that when doing a relocateable link the symbol indexused in the output file can be quickly filled in when copying over areloc). The a.out linker code defines the required structures andfunctions for a hash table derived from `struct bfd_link_hash_table'.The a.out linker hash table is created by the function`NAME(aout,link_hash_table_create)'; it simply allocates space for thehash table, initializes it, and returns a pointer to it.When writing the linker routines for a new back end, you willgenerally not know exactly which fields will be required until you havefinished. You should simply create a new hash table which defines noadditional fields, and then simply add fields as they become necessary.File: bfd.info, Node: Adding Symbols to the Hash Table, Next: Performing the Final Link, Prev: Creating a Linker Hash Table, Up: Linker FunctionsAdding symbols to the hash table--------------------------------The linker proper will call the `_bfd_link_add_symbols' entry pointfor each object file or archive which is to be linked (typically theseare the files named on the command line, but some may also come fromthe linker script). The entry point is responsible for examining thefile. For an object file, BFD must add any relevant symbol informationto the hash table. For an archive, BFD must determine which elementsof the archive should be used and adding them to the link.The a.out version of this entry point is`NAME(aout,link_add_symbols)'.* Menu:* Differing file formats::* Adding symbols from an object file::* Adding symbols from an archive::File: bfd.info, Node: Differing file formats, Next: Adding symbols from an object file, Prev: Adding Symbols to the Hash Table, Up: Adding Symbols to the Hash TableDiffering file formats......................Normally all the files involved in a link will be of the sameformat, but it is also possible to link together different formatobject files, and the back end must support that. The`_bfd_link_add_symbols' entry point is called via the target vector ofthe file to be added. This has an important consequence: the functionmay not assume that the hash table is the type created by thecorresponding `_bfd_link_hash_table_create' vector. All the`_bfd_link_add_symbols' function can assume about the hash table isthat it is derived from `struct bfd_link_hash_table'.Sometimes the `_bfd_link_add_symbols' function must store someinformation in the hash table entry to be used by the `_bfd_final_link'function. In such a case the `creator' field of the hash table must bechecked to make sure that the hash table was created by an object fileof the same format.The `_bfd_final_link' routine must be prepared to handle a hashentry without any extra information added by the`_bfd_link_add_symbols' function. A hash entry without extrainformation will also occur when the linker script directs the linkerto create a symbol. Note that, regardless of how a hash table entry isadded, all the fields will be initialized to some sort of null value bythe hash table entry initialization function.See `ecoff_link_add_externals' for an example of how to check the`creator' field before saving information (in this case, the ECOFFexternal symbol debugging information) in a hash table entry.File: bfd.info, Node: Adding symbols from an object file, Next: Adding symbols from an archive, Prev: Differing file formats, Up: Adding Symbols to the Hash TableAdding symbols from an object file..................................When the `_bfd_link_add_symbols' routine is passed an object file,it must add all externally visible symbols in that object file to thehash table. The actual work of adding the symbol to the hash table isnormally handled by the function `_bfd_generic_link_add_one_symbol'.The `_bfd_link_add_symbols' routine is responsible for reading all thesymbols from the object file and passing the correct information to`_bfd_generic_link_add_one_symbol'.The `_bfd_link_add_symbols' routine should not use`bfd_canonicalize_symtab' to read the symbols. The point of providingthis routine is to avoid the overhead of converting the symbols intogeneric `asymbol' structures.`_bfd_generic_link_add_one_symbol' handles the details of combiningcommon symbols, warning about multiple definitions, and so forth. Ittakes arguments which describe the symbol to add, notably symbol flags,a section, and an offset. The symbol flags include such things as`BSF_WEAK' or `BSF_INDIRECT'. The section is a section in the objectfile, or something like `bfd_und_section_ptr' for an undefined symbolor `bfd_com_section_ptr' for a common symbol.If the `_bfd_final_link' routine is also going to need to read thesymbol information, the `_bfd_link_add_symbols' routine should save itsomewhere attached to the object file BFD. However, the informationshould only be saved if the `keep_memory' field of the `info' argumentis true, so that the `-no-keep-memory' linker switch is effective.The a.out function which adds symbols from an object file is`aout_link_add_object_symbols', and most of the interesting work is in`aout_link_add_symbols'. The latter saves pointers to the hash tablesentries created by `_bfd_generic_link_add_one_symbol' indexed by symbolnumber, so that the `_bfd_final_link' routine does not have to call thehash table lookup routine to locate the entry.File: bfd.info, Node: Adding symbols from an archive, Prev: Adding symbols from an object file, Up: Adding Symbols to the Hash TableAdding symbols from an archive..............................When the `_bfd_link_add_symbols' routine is passed an archive, itmust look through the symbols defined by the archive and decide whichelements of the archive should be included in the link. For each suchelement it must call the `add_archive_element' linker callback, and itmust add the symbols from the object file to the linker hash table.In most cases the work of looking through the symbols in the archiveshould be done by the `_bfd_generic_link_add_archive_symbols' function.This function builds a hash table from the archive symbol table andlooks through the list of undefined symbols to see which elementsshould be included. `_bfd_generic_link_add_archive_symbols' is passeda function to call to make the final decision about adding an archiveelement to the link and to do the actual work of adding the symbols tothe linker hash table.The function passed to `_bfd_generic_link_add_archive_symbols' mustread the symbols of the archive element and decide whether the archiveelement should be included in the link. If the element is to beincluded, the `add_archive_element' linker callback routine must becalled with the element as an argument, and the elements symbols mustbe added to the linker hash table just as though the element had itselfbeen passed to the `_bfd_link_add_symbols' function.When the a.out `_bfd_link_add_symbols' function receives an archive,it calls `_bfd_generic_link_add_archive_symbols' passing`aout_link_check_archive_element' as the function argument.`aout_link_check_archive_element' calls `aout_link_check_ar_symbols'.If the latter decides to add the element (an element is only added ifit provides a real, non-common, definition for a previously undefinedor common symbol) it calls the `add_archive_element' callback and then`aout_link_check_archive_element' calls `aout_link_add_symbols' toactually add the symbols to the linker hash table.The ECOFF back end is unusual in that it does not normally call`_bfd_generic_link_add_archive_symbols', because ECOFF archives alreadycontain a hash table of symbols. The ECOFF back end searches thearchive itself to avoid the overhead of creating a new hash table.File: bfd.info, Node: Performing the Final Link, Prev: Adding Symbols to the Hash Table, Up: Linker FunctionsPerforming the final link-------------------------When all the input files have been processed, the linker calls the`_bfd_final_link' entry point of the output BFD. This routine isresponsible for producing the final output file, which has severalaspects. It must relocate the contents of the input sections and copythe data into the output sections. It must build an output symboltable including any local symbols from the input files and the globalsymbols from the hash table. When producing relocateable output, itmust modify the input relocs and write them into the output file.There may also be object format dependent work to be done.The linker will also call the `write_object_contents' entry pointwhen the BFD is closed. The two entry points must work together inorder to produce the correct output file.The details of how this works are inevitably dependent upon thespecific object file format. The a.out `_bfd_final_link' routine is`NAME(aout,final_link)'.* Menu:* Information provided by the linker::* Relocating the section contents::* Writing the symbol table::File: bfd.info, Node: Information provided by the linker, Next: Relocating the section contents, Prev: Performing the Final Link, Up: Performing the Final LinkInformation provided by the linker..................................Before the linker calls the `_bfd_final_link' entry point, it setsup some data structures for the function to use.The `input_bfds' field of the `bfd_link_info' structure will pointto a list of all the input files included in the link. These files arelinked through the `link_next' field of the `bfd' structure.Each section in the output file will have a list of `link_order'structures attached to the `link_order_head' field (the `link_order'structure is defined in `bfdlink.h'). These structures describe how tocreate the contents of the output section in terms of the contents ofvarious input sections, fill constants, and, eventually, other types ofinformation. They also describe relocs that must be created by the BFDbackend, but do not correspond to any input file; this is used tosupport -Ur, which builds constructors while generating a relocateableobject file.File: bfd.info, Node: Relocating the section contents, Next: Writing the symbol table, Prev: Information provided by the linker, Up: Performing the Final LinkRelocating the section contents...............................The `_bfd_final_link' function should look through the `link_order'structures attached to each section of the output file. Each`link_order' structure should either be handled specially, or it shouldbe passed to the function `_bfd_default_link_order' which will do theright thing (`_bfd_default_link_order' is defined in `linker.c').For efficiency, a `link_order' of type `bfd_indirect_link_order'whose associated section belongs to a BFD of the same format as theoutput BFD must be handled specially. This type of `link_order'describes part of an output section in terms of a section belonging toone of the input files. The `_bfd_final_link' function should read thecontents of the section and any associated relocs, apply the relocs tothe section contents, and write out the modified section contents. Ifperforming a relocateable link, the relocs themselves must also bemodified and written out.The functions `_bfd_relocate_contents' and`_bfd_final_link_relocate' provide some general support for performingthe actual relocations, notably overflow checking. Their argumentsinclude information about the symbol the relocation is against and a`reloc_howto_type' argument which describes the relocation to perform.These functions are defined in `reloc.c'.The a.out function which handles reading, relocating, and writingsection contents is `aout_link_input_section'. The actual relocationis done in `aout_link_input_section_std' and`aout_link_input_section_ext'.File: bfd.info, Node: Writing the symbol table, Prev: Relocating the section contents, Up: Performing the Final LinkWriting the symbol table........................The `_bfd_final_link' function must gather all the symbols in theinput files and write them out. It must also write out all the symbolsin the global hash table. This must be controlled by the `strip' and`discard' fields of the `bfd_link_info' structure.The local symbols of the input files will not have been entered intothe linker hash table. The `_bfd_final_link' routine must considereach input file and include the symbols in the output file. It may beconvenient to do this when looking through the `link_order' structures,or it may be done by stepping through the `input_bfds' list.The `_bfd_final_link' routine must also traverse the global hashtable to gather all the externally visible symbols. It is possiblethat most of the externally visible symbols may be written out whenconsidering the symbols of each input file, but it is still necessaryto traverse the hash table since the linker script may have definedsome symbols that are not in any of the input files.The `strip' field of the `bfd_link_info' structure controls whichsymbols are written out. The possible values are listed in`bfdlink.h'. If the value is `strip_some', then the `keep_hash' fieldof the `bfd_link_info' structure is a hash table of symbols to keep;each symbol should be looked up in this hash table, and only symbolswhich are present should be included in the output file.If the `strip' field of the `bfd_link_info' structure permits localsymbols to be written out, the `discard' field is used to furthercontrols which local symbols are included in the output file. If thevalue is `discard_l', then all local symbols which begin with a certainprefix are discarded; this is controlled by the`bfd_is_local_label_name' entry point.The a.out backend handles symbols by calling`aout_link_write_symbols' on each input BFD and then traversing theglobal hash table with the function `aout_link_write_other_symbol'. Itbuilds a string table while writing out the symbols, which is writtento the output file at the end of `NAME(aout,final_link)'.`bfd_link_split_section'........................*Synopsis*boolean bfd_link_split_section(bfd *abfd, asection *sec);*Description*Return nonzero if SEC should be split during a reloceatable or finallink.#define bfd_link_split_section(abfd, sec) \BFD_SEND (abfd, _bfd_link_split_section, (abfd, sec))File: bfd.info, Node: Hash Tables, Prev: Linker Functions, Up: BFD front endHash Tables===========BFD provides a simple set of hash table functions. Routines areprovided to initialize a hash table, to free a hash table, to look up astring in a hash table and optionally create an entry for it, and totraverse a hash table. There is currently no routine to delete anstring from a hash table.The basic hash table does not permit any data to be stored with astring. However, a hash table is designed to present a base class fromwhich other types of hash tables may be derived. These derived typesmay store additional information with the string. Hash tables wereimplemented in this way, rather than simply providing a data pointer ina hash table entry, because they were designed for use by the linkerback ends. The linker may create thousands of hash table entries, andthe overhead of allocating private data and storing and followingpointers becomes noticeable.The basic hash table code is in `hash.c'.* Menu:* Creating and Freeing a Hash Table::* Looking Up or Entering a String::* Traversing a Hash Table::* Deriving a New Hash Table Type::File: bfd.info, Node: Creating and Freeing a Hash Table, Next: Looking Up or Entering a String, Prev: Hash Tables, Up: Hash TablesCreating and freeing a hash table---------------------------------To create a hash table, create an instance of a `structbfd_hash_table' (defined in `bfd.h') and call `bfd_hash_table_init' (ifyou know approximately how many entries you will need, the function`bfd_hash_table_init_n', which takes a SIZE argument, may be used).`bfd_hash_table_init' returns `false' if some sort of error occurs.The function `bfd_hash_table_init' take as an argument a function touse to create new entries. For a basic hash table, use the function`bfd_hash_newfunc'. *Note Deriving a New Hash Table Type::, for whyyou would want to use a different value for this argument.`bfd_hash_table_init' will create an objalloc which will be used toallocate new entries. You may allocate memory on this objalloc using`bfd_hash_allocate'.Use `bfd_hash_table_free' to free up all the memory that has beenallocated for a hash table. This will not free up the `structbfd_hash_table' itself, which you must provide.File: bfd.info, Node: Looking Up or Entering a String, Next: Traversing a Hash Table, Prev: Creating and Freeing a Hash Table, Up: Hash TablesLooking up or entering a string-------------------------------The function `bfd_hash_lookup' is used both to look up a string inthe hash table and to create a new entry.If the CREATE argument is `false', `bfd_hash_lookup' will look up astring. If the string is found, it will returns a pointer to a `structbfd_hash_entry'. If the string is not found in the table`bfd_hash_lookup' will return `NULL'. You should not modify any of thefields in the returns `struct bfd_hash_entry'.If the CREATE argument is `true', the string will be entered intothe hash table if it is not already there. Either way a pointer to a`struct bfd_hash_entry' will be returned, either to the existingstructure or to a newly created one. In this case, a `NULL' returnmeans that an error occurred.If the CREATE argument is `true', and a new entry is created, theCOPY argument is used to decide whether to copy the string onto thehash table objalloc or not. If COPY is passed as `false', you must becareful not to deallocate or modify the string as long as the hash tableexists.File: bfd.info, Node: Traversing a Hash Table, Next: Deriving a New Hash Table Type, Prev: Looking Up or Entering a String, Up: Hash TablesTraversing a hash table-----------------------The function `bfd_hash_traverse' may be used to traverse a hashtable, calling a function on each element. The traversal is done in arandom order.`bfd_hash_traverse' takes as arguments a function and a generic`void *' pointer. The function is called with a hash table entry (a`struct bfd_hash_entry *') and the generic pointer passed to`bfd_hash_traverse'. The function must return a `boolean' value, whichindicates whether to continue traversing the hash table. If thefunction returns `false', `bfd_hash_traverse' will stop the traversaland return immediately.File: bfd.info, Node: Deriving a New Hash Table Type, Prev: Traversing a Hash Table, Up: Hash TablesDeriving a new hash table type------------------------------Many uses of hash tables want to store additional information whicheach entry in the hash table. Some also find it convenient to storeadditional information with the hash table itself. This may be doneusing a derived hash table.Since C is not an object oriented language, creating a derived hashtable requires sticking together some boilerplate routines with a fewdifferences specific to the type of hash table you want to create.An example of a derived hash table is the linker hash table. Thestructures for this are defined in `bfdlink.h'. The functions are in`linker.c'.You may also derive a hash table from an already derived hash table.For example, the a.out linker backend code uses a hash table derivedfrom the linker hash table.* Menu:* Define the Derived Structures::* Write the Derived Creation Routine::* Write Other Derived Routines::File: bfd.info, Node: Define the Derived Structures, Next: Write the Derived Creation Routine, Prev: Deriving a New Hash Table Type, Up: Deriving a New Hash Table TypeDefine the derived structures.............................You must define a structure for an entry in the hash table, and astructure for the hash table itself.The first field in the structure for an entry in the hash table mustbe of the type used for an entry in the hash table you are derivingfrom. If you are deriving from a basic hash table this is `structbfd_hash_entry', which is defined in `bfd.h'. The first field in thestructure for the hash table itself must be of the type of the hashtable you are deriving from itself. If you are deriving from a basichash table, this is `struct bfd_hash_table'.For example, the linker hash table defines `structbfd_link_hash_entry' (in `bfdlink.h'). The first field, `root', is oftype `struct bfd_hash_entry'. Similarly, the first field in `structbfd_link_hash_table', `table', is of type `struct bfd_hash_table'.File: bfd.info, Node: Write the Derived Creation Routine, Next: Write Other Derived Routines, Prev: Define the Derived Structures, Up: Deriving a New Hash Table TypeWrite the derived creation routine..................................You must write a routine which will create and initialize an entryin the hash table. This routine is passed as the function argument to`bfd_hash_table_init'.In order to permit other hash tables to be derived from the hashtable you are creating, this routine must be written in a standard way.The first argument to the creation routine is a pointer to a hashtable entry. This may be `NULL', in which case the routine shouldallocate the right amount of space. Otherwise the space has alreadybeen allocated by a hash table type derived from this one.After allocating space, the creation routine must call the creationroutine of the hash table type it is derived from, passing in a pointerto the space it just allocated. This will initialize any fields usedby the base hash table.Finally the creation routine must initialize any local fields forthe new hash table type.Here is a boilerplate example of a creation routine. FUNCTION_NAMEis the name of the routine. ENTRY_TYPE is the type of an entry in thehash table you are creating. BASE_NEWFUNC is the name of the creationroutine of the hash table type your hash table is derived from.struct bfd_hash_entry *FUNCTION_NAME (entry, table, string)struct bfd_hash_entry *entry;struct bfd_hash_table *table;const char *string;{struct ENTRY_TYPE *ret = (ENTRY_TYPE *) entry;/* Allocate the structure if it has not already been allocated by aderived class. */if (ret == (ENTRY_TYPE *) NULL){ret = ((ENTRY_TYPE *)bfd_hash_allocate (table, sizeof (ENTRY_TYPE)));if (ret == (ENTRY_TYPE *) NULL)return NULL;}/* Call the allocation method of the base class. */ret = ((ENTRY_TYPE *)BASE_NEWFUNC ((struct bfd_hash_entry *) ret, table, string));/* Initialize the local fields here. */return (struct bfd_hash_entry *) ret;}*Description*The creation routine for the linker hash table, which is in `linker.c',looks just like this example. FUNCTION_NAME is`_bfd_link_hash_newfunc'. ENTRY_TYPE is `struct bfd_link_hash_entry'.BASE_NEWFUNC is `bfd_hash_newfunc', the creation routine for a basichash table.`_bfd_link_hash_newfunc' also initializes the local fields in alinker hash table entry: `type', `written' and `next'.File: bfd.info, Node: Write Other Derived Routines, Prev: Write the Derived Creation Routine, Up: Deriving a New Hash Table TypeWrite other derived routines............................You will want to write other routines for your new hash table, aswell.You will want an initialization routine which calls theinitialization routine of the hash table you are deriving from andinitializes any other local fields. For the linker hash table, this is`_bfd_link_hash_table_init' in `linker.c'.You will want a lookup routine which calls the lookup routine of thehash table you are deriving from and casts the result. The linker hashtable uses `bfd_link_hash_lookup' in `linker.c' (this actually takes anadditional argument which it uses to decide how to return the looked upvalue).You may want a traversal routine. This should just call thetraversal routine of the hash table you are deriving from withappropriate casts. The linker hash table uses `bfd_link_hash_traverse'in `linker.c'.These routines may simply be defined as macros. For example, thea.out backend linker hash table, which is derived from the linker hashtable, uses macros for the lookup and traversal routines. These are`aout_link_hash_lookup' and `aout_link_hash_traverse' in aoutx.h.File: bfd.info, Node: BFD back ends, Next: GNU Free Documentation License, Prev: BFD front end, Up: TopBFD back ends************** Menu:* What to Put Where::* aout :: a.out backends* coff :: coff backends* elf :: elf backendsFile: bfd.info, Node: What to Put Where, Next: aout, Prev: BFD back ends, Up: BFD back endsAll of BFD lives in one directory.File: bfd.info, Node: aout, Next: coff, Prev: What to Put Where, Up: BFD back endsa.out backends==============*Description*BFD supports a number of different flavours of a.out format, though themajor differences are only the sizes of the structures on disk, and theshape of the relocation information.The support is split into a basic support file `aoutx.h' and otherfiles which derive functions from the base. One derivation file is`aoutf1.h' (for a.out flavour 1), and adds to the basic a.out functionssupport for sun3, sun4, 386 and 29k a.out files, to create a targetjump vector for a specific target.This information is further split out into more specific files foreach machine, including `sunos.c' for sun3 and sun4, `newsos3.c' forthe Sony NEWS, and `demo64.c' for a demonstration of a 64 bit a.outformat.The base file `aoutx.h' defines general mechanisms for reading andwriting records to and from disk and various other methods which BFDrequires. It is included by `aout32.c' and `aout64.c' to form the names`aout_32_swap_exec_header_in', `aout_64_swap_exec_header_in', etc.As an example, this is what goes on to make the back end for a sun4,from `aout32.c':#define ARCH_SIZE 32#include "aoutx.h"Which exports names:...aout_32_canonicalize_relocaout_32_find_nearest_lineaout_32_get_linenoaout_32_get_reloc_upper_bound...from `sunos.c':#define TARGET_NAME "a.out-sunos-big"#define VECNAME sunos_big_vec#include "aoutf1.h"requires all the names from `aout32.c', and produces the jump vectorsunos_big_vecThe file `host-aout.c' is a special case. It is for a large set ofhosts that use "more or less standard" a.out files, and for whichcross-debugging is not interesting. It uses the standard 32-bit a.outsupport routines, but determines the file offsets and addresses of thetext, data, and BSS sections, the machine architecture and machinetype, and the entry point address, in a host-dependent manner. Oncethese values have been determined, generic code is used to handle theobject file.When porting it to run on a new system, you must supply:HOST_PAGE_SIZEHOST_SEGMENT_SIZEHOST_MACHINE_ARCH (optional)HOST_MACHINE_MACHINE (optional)HOST_TEXT_START_ADDRHOST_STACK_END_ADDRin the file `../include/sys/h-XXX.h' (for your host). These values,plus the structures and macros defined in `a.out.h' on your hostsystem, will produce a BFD target that will access ordinary a.out fileson your host. To configure a new machine to use `host-aout.c', specify:TDEFAULTS = -DDEFAULT_VECTOR=host_aout_big_vecTDEPFILES= host-aout.o trad-core.oin the `config/XXX.mt' file, and modify `configure.in' to use the`XXX.mt' file (by setting "`bfd_target=XXX'") when your configurationis selected.Relocations-----------*Description*The file `aoutx.h' provides for both the _standard_ and _extended_forms of a.out relocation records.The standard records contain only an address, a symbol index, and atype field. The extended records (used on 29ks and sparcs) also have afull integer for an addend.Internal entry points---------------------*Description*`aoutx.h' exports several routines for accessing the contents of ana.out file, which are gathered and exported in turn by various formatspecific files (eg sunos.c).`aout_SIZE_swap_exec_header_in'...............................*Synopsis*void aout_SIZE_swap_exec_header_in,(bfd *abfd,struct external_exec *raw_bytes,struct internal_exec *execp);*Description*Swap the information in an executable header RAW_BYTES taken from a rawbyte stream memory image into the internal exec header structure EXECP.`aout_SIZE_swap_exec_header_out'................................*Synopsis*void aout_SIZE_swap_exec_header_out(bfd *abfd,struct internal_exec *execp,struct external_exec *raw_bytes);*Description*Swap the information in an internal exec header structure EXECP intothe buffer RAW_BYTES ready for writing to disk.`aout_SIZE_some_aout_object_p'..............................*Synopsis*const bfd_target *aout_SIZE_some_aout_object_p(bfd *abfd,const bfd_target *(*callback_to_real_object_p) ());*Description*Some a.out variant thinks that the file open in ABFD checking is ana.out file. Do some more checking, and set up for access if it reallyis. Call back to the calling environment's "finish up" function justbefore returning, to handle any last-minute setup.`aout_SIZE_mkobject'....................*Synopsis*boolean aout_SIZE_mkobject, (bfd *abfd);*Description*Initialize BFD ABFD for use with a.out files.`aout_SIZE_machine_type'........................*Synopsis*enum machine_type aout_SIZE_machine_type(enum bfd_architecture arch,unsigned long machine));*Description*Keep track of machine architecture and machine type for a.out's. Returnthe `machine_type' for a particular architecture and machine, or`M_UNKNOWN' if that exact architecture and machine can't be representedin a.out format.If the architecture is understood, machine type 0 (default) isalways understood.`aout_SIZE_set_arch_mach'.........................*Synopsis*boolean aout_SIZE_set_arch_mach,(bfd *,enum bfd_architecture arch,unsigned long machine));*Description*Set the architecture and the machine of the BFD ABFD to the values ARCHand MACHINE. Verify that ABFD's format can support the architecturerequired.`aout_SIZE_new_section_hook'............................*Synopsis*boolean aout_SIZE_new_section_hook,(bfd *abfd,asection *newsect));*Description*Called by the BFD in response to a `bfd_make_section' request.
Go to most recent revision | Compare with Previous | Blame | View Log
