Next: , Previous: Adding Symbols to the Hash Table, Up: Adding Symbols to the Hash Table



2.17.2.1 Differing file formats

Normally all the files involved in a link will be of the same format, but it is also possible to link together different format object files, and the back end must support that. The _bfd_link_add_symbols entry point is called via the target vector of the file to be added. This has an important consequence: the function may not assume that the hash table is the type created by the corresponding _bfd_link_hash_table_create vector. All the _bfd_link_add_symbols function can assume about the hash table is that it is derived from struct bfd_link_hash_table.

Sometimes the _bfd_link_add_symbols function must store some information in the hash table entry to be used by the _bfd_final_link function. In such a case the output bfd xvec must be checked to make sure that the hash table was created by an object file of the same format.

The _bfd_final_link routine must be prepared to handle a hash entry without any extra information added by the _bfd_link_add_symbols function. A hash entry without extra information will also occur when the linker script directs the linker to create a symbol. Note that, regardless of how a hash table entry is added, all the fields will be initialized to some sort of null value by the hash table entry initialization function.

See ecoff_link_add_externals for an example of how to check the output bfd before saving information (in this case, the ECOFF external symbol debugging information) in a hash table entry.