Previous: Write the derived creation routine, Up: Deriving a new hash table type [Contents][Index]
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.
bfd_hash_table_init_n ¶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.
bfd_hash_table_init ¶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.
bfd_hash_table_free ¶void bfd_hash_table_free (struct bfd_hash_table *); ¶Free a hash table.
bfd_hash_lookup ¶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.
bfd_hash_insert ¶struct bfd_hash_entry *bfd_hash_insert (struct bfd_hash_table *, const char *, unsigned long *hash*); ¶Insert an entry in a hash table.
bfd_hash_rename ¶void bfd_hash_rename (struct bfd_hash_table *, const char *, struct bfd_hash_entry *); ¶Rename an entry in a hash table.
bfd_hash_replace ¶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.
bfd_hash_allocate ¶void *bfd_hash_allocate (struct bfd_hash_table *, unsigned int *size*); ¶Allocate space in a hash table.
bfd_hash_newfunc ¶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.
bfd_hash_traverse ¶void bfd_hash_traverse (struct bfd_hash_table *, bool (*) (struct bfd_hash_entry *, void *), void *); ¶Traverse a hash table.
bfd_hash_set_default_size ¶unsigned int bfd_hash_set_default_size (unsigned int); ¶Set hash table default size.
_bfd_stringtab_init ¶struct bfd_strtab_hash *_bfd_stringtab_init (void); ¶Create a new strtab.
_bfd_xcoff_stringtab_init ¶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.
_bfd_stringtab_free ¶void _bfd_stringtab_free (struct bfd_strtab_hash *); ¶Free a strtab.
_bfd_stringtab_add ¶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.
_bfd_stringtab_size ¶bfd_size_type _bfd_stringtab_size (struct bfd_strtab_hash *); ¶Get the number of bytes in a strtab.
_bfd_stringtab_emit ¶bool _bfd_stringtab_emit (bfd *, struct bfd_strtab_hash *); ¶Write out a strtab. ABFD must already be at the right location in the file.
Previous: Write the derived creation routine, Up: Deriving a new hash table type [Contents][Index]