Next: , Previous: Linker Functions, Up: Linker Functions


2.17.1 Creating a linker hash table

The linker routines must create a hash table, which must be derived from struct bfd_link_hash_table described in bfdlink.c. See Hash Tables, for information on how to create a derived hash table. This entry point is called using the target vector of the linker output file.

The _bfd_link_hash_table_create entry point must allocate and initialize an instance of the desired hash table. If the back end does not require any additional information to be stored with the entries in the hash table, the entry point may simply create a struct bfd_link_hash_table. Most likely, however, some additional information will be needed.

For example, with each entry in the hash table the a.out linker keeps the index the symbol has in the final output file (this index number is used so that when doing a relocatable link the symbol index used in the output file can be quickly filled in when copying over a reloc). The a.out linker code defines the required structures and functions 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 the hash table, initializes it, and returns a pointer to it.

When writing the linker routines for a new back end, you will generally not know exactly which fields will be required until you have finished. You should simply create a new hash table which defines no additional fields, and then simply add fields as they become necessary.