2.18.4.3 Write other derived routines

You will want to write other routines for your new hash table, as well.

You will want an initialization routine which calls the initialization routine of the hash table you are deriving from and initializes 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 the hash table you are deriving from and casts the result. The linker hash table uses bfd_link_hash_lookup in linker.c (this actually takes an additional argument which it uses to decide how to return the looked up value).

You may want a traversal routine. This should just call the traversal routine of the hash table you are deriving from with appropriate casts. The linker hash table uses bfd_link_hash_traverse in linker.c.

These routines may simply be defined as macros. For example, the a.out backend linker hash table, which is derived from the linker hash table, uses macros for the lookup and traversal routines. These are aout_link_hash_lookup and aout_link_hash_traverse in aoutx.h.

2.18.4.4 bfd_hash_table_init_n

Function: bool bfd_hash_table_init_n (struct bfd_hash_table *, struct bfd_hash_entry *(* *newfunc*) (struct bfd_hash_entry *, struct bfd_hash_table *, const char *), unsigned int *entsize*, unsigned int *size*);

Create a new hash table, given a number of entries.

2.18.4.5 bfd_hash_table_init

Function: bool bfd_hash_table_init (struct bfd_hash_table *, struct bfd_hash_entry *(* *newfunc*) (struct bfd_hash_entry *, struct bfd_hash_table *, const char *), unsigned int *entsize*);

Create a new hash table with the default number of entries.

2.18.4.6 bfd_hash_table_free

Function: void bfd_hash_table_free (struct bfd_hash_table *);

Free a hash table.

2.18.4.7 bfd_hash_lookup

Function: struct bfd_hash_entry *bfd_hash_lookup (struct bfd_hash_table *, const char *, bool *create*, bool *copy*);

Look up a string in a hash table.

2.18.4.8 bfd_hash_insert

Function: struct bfd_hash_entry *bfd_hash_insert (struct bfd_hash_table *, const char *, unsigned long *hash*);

Insert an entry in a hash table.

2.18.4.9 bfd_hash_rename

Function: void bfd_hash_rename (struct bfd_hash_table *, const char *, struct bfd_hash_entry *);

Rename an entry in a hash table.

2.18.4.10 bfd_hash_replace

Function: void bfd_hash_replace (struct bfd_hash_table *, struct bfd_hash_entry * *old*, struct bfd_hash_entry * *new*);

Replace an entry in a hash table.

2.18.4.11 bfd_hash_allocate

Function: void *bfd_hash_allocate (struct bfd_hash_table *, unsigned int *size*);

Allocate space in a hash table.

2.18.4.12 bfd_hash_newfunc

Function: struct bfd_hash_entry *bfd_hash_newfunc (struct bfd_hash_entry *, struct bfd_hash_table *, const char *);

Base method for creating a new hash table entry.

2.18.4.13 bfd_hash_traverse

Function: void bfd_hash_traverse (struct bfd_hash_table *, bool (*) (struct bfd_hash_entry *, void *), void *);

Traverse a hash table.

2.18.4.14 bfd_hash_set_default_size

Function: unsigned int bfd_hash_set_default_size (unsigned int);

Set hash table default size.

2.18.4.15 _bfd_stringtab_init

Function: struct bfd_strtab_hash *_bfd_stringtab_init (void);

Create a new strtab.

2.18.4.16 _bfd_xcoff_stringtab_init

Function: struct bfd_strtab_hash *_bfd_xcoff_stringtab_init (bool *isxcoff64*);

Create a new strtab in which the strings are output in the format used in the XCOFF .debug section: a two byte length precedes each string.

2.18.4.17 _bfd_stringtab_free

Function: void _bfd_stringtab_free (struct bfd_strtab_hash *);

Free a strtab.

2.18.4.18 _bfd_stringtab_add

Function: bfd_size_type _bfd_stringtab_add (struct bfd_strtab_hash *, const char *, bool *hash*, bool *copy*);

Get the index of a string in a strtab, adding it if it is not already present. If HASH is FALSE, we don’t really use the hash table, and we don’t eliminate duplicate strings. If COPY is true then store a copy of STR if creating a new entry.

2.18.4.19 _bfd_stringtab_size

Function: bfd_size_type _bfd_stringtab_size (struct bfd_strtab_hash *);

Get the number of bytes in a strtab.

2.18.4.20 _bfd_stringtab_emit

Function: bool _bfd_stringtab_emit (bfd *, struct bfd_strtab_hash *);

Write out a strtab. ABFD must already be at the right location in the file.