forked from Imagelibrary/binutils-gdb
Add section caches to coff_data_type
* libcoff-in.h (struct coff_tdata): Add section_by_index and section_by_target_index hash tables. * libcoff.h: Regenerate. * coffcode.h (htab_hash_section_index): New function. (htab_eq_section_index): New function. (htab_hash_section_target_index): New function. (htab_eq_section_target_index): New function. (coff_mkobject_hool): Create the hash tables. * peicode.h: Add the same new functions. (pe_mkobject_hook): Create the hash tables. * coff-x86_64.c (coff_amd64_rtype_to_howto): Use the new tables to speed up lookups. * coffgen.c (coff_section_from_bfd_index): Likewise. (_bfd_coff_close_and_cleanup): Delete the hash tables.
This commit is contained in:
committed by
Nick Clifton
parent
73eff1cbd3
commit
0e759f232b
@@ -731,6 +731,36 @@ sec_to_styp_flags (const char *sec_name, flagword sec_flags)
|
||||
|
||||
#ifndef COFF_WITH_PE
|
||||
|
||||
static hashval_t
|
||||
htab_hash_section_index (const void * entry)
|
||||
{
|
||||
const struct bfd_section * sec = entry;
|
||||
return sec->index;
|
||||
}
|
||||
|
||||
static int
|
||||
htab_eq_section_index (const void * e1, const void * e2)
|
||||
{
|
||||
const struct bfd_section * sec1 = e1;
|
||||
const struct bfd_section * sec2 = e2;
|
||||
return sec1->index == sec2->index;
|
||||
}
|
||||
|
||||
static hashval_t
|
||||
htab_hash_section_target_index (const void * entry)
|
||||
{
|
||||
const struct bfd_section * sec = entry;
|
||||
return sec->target_index;
|
||||
}
|
||||
|
||||
static int
|
||||
htab_eq_section_target_index (const void * e1, const void * e2)
|
||||
{
|
||||
const struct bfd_section * sec1 = e1;
|
||||
const struct bfd_section * sec2 = e2;
|
||||
return sec1->target_index == sec2->target_index;
|
||||
}
|
||||
|
||||
static bool
|
||||
styp_to_sec_flags (bfd *abfd,
|
||||
void * hdr,
|
||||
@@ -2062,6 +2092,7 @@ coff_mkobject (bfd * abfd)
|
||||
abfd->tdata.coff_obj_data = bfd_zalloc (abfd, amt);
|
||||
if (abfd->tdata.coff_obj_data == NULL)
|
||||
return false;
|
||||
|
||||
coff = coff_data (abfd);
|
||||
coff->symbols = NULL;
|
||||
coff->conversion_table = NULL;
|
||||
@@ -2154,6 +2185,11 @@ coff_mkobject_hook (bfd * abfd,
|
||||
abfd->flags |= HAS_DEBUG;
|
||||
#endif
|
||||
|
||||
coff->section_by_index
|
||||
= htab_create (10, htab_hash_section_index, htab_eq_section_index, NULL);
|
||||
coff->section_by_target_index = htab_create
|
||||
(10, htab_hash_section_target_index, htab_eq_section_target_index, NULL);
|
||||
|
||||
return coff;
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user