mirror of
https://sourceware.org/git/binutils-gdb.git
synced 2024-11-24 10:35:12 +08:00
Re: Add section caches to coff_data_type
Commit0e759f232b
regressed these tests: rs6000-aix7.2 +FAIL: Garbage collection test 1 (32-bit) rs6000-aix7.2 +FAIL: Garbage collection test 1 (64-bit) rs6000-aix7.2 +FAIL: Glink test 1 (32-bit) rs6000-aix7.2 +FAIL: Glink test 1 (64-bit) Investigation showed segfaults in coff_section_from_bfd_index called by xcoff_write_global_symbol due to the hash table pointer being NULL. Well, yes, the hash table isn't initialised for the output bfd. mkobject_hook is the wrong place to do that. * coffcode.h: Revert0e759f232b
changes. * peicode.h: Likewise. * coff-x86_64.c (htab_hash_section_index, htab_eq_section_index): Moved here from coffcode.h. (coff_amd64_rtype_to_howto): Create section_by_index htab. * coffgen.c (htab_hash_section_target_index), (htab_eq_section_target_index): Moved here from coffcode.h. (coff_section_from_bfd_index): Create section_by_target_index htab. Stash newly created sections in htab.
This commit is contained in:
parent
4cb88cfae8
commit
0cc8cc5e6f
@ -656,6 +656,20 @@ coff_pe_amd64_relocate_section (bfd *output_bfd,
|
|||||||
|
|
||||||
#define coff_relocate_section coff_pe_amd64_relocate_section
|
#define coff_relocate_section coff_pe_amd64_relocate_section
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
#endif /* COFF_WITH_PE */
|
#endif /* COFF_WITH_PE */
|
||||||
|
|
||||||
/* Convert an rtype to howto for the COFF backend linker. */
|
/* Convert an rtype to howto for the COFF backend linker. */
|
||||||
@ -756,11 +770,17 @@ coff_amd64_rtype_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
|
|||||||
htab_t table = coff_data (abfd)->section_by_index;
|
htab_t table = coff_data (abfd)->section_by_index;
|
||||||
asection *s;
|
asection *s;
|
||||||
|
|
||||||
|
if (!table)
|
||||||
|
{
|
||||||
|
table = htab_create (10, htab_hash_section_index,
|
||||||
|
htab_eq_section_index, NULL);
|
||||||
|
if (table == NULL)
|
||||||
|
return NULL;
|
||||||
|
coff_data (abfd)->section_by_index = table;
|
||||||
|
}
|
||||||
|
|
||||||
if (htab_elements (table) == 0)
|
if (htab_elements (table) == 0)
|
||||||
{
|
{
|
||||||
/* Sigh - if we do not have a section index then the only way
|
|
||||||
to get the section to offset against is to find it the hard
|
|
||||||
way. */
|
|
||||||
for (s = abfd->sections; s != NULL; s = s->next)
|
for (s = abfd->sections; s != NULL; s = s->next)
|
||||||
{
|
{
|
||||||
void ** slot = htab_find_slot (table, s, INSERT);
|
void ** slot = htab_find_slot (table, s, INSERT);
|
||||||
|
@ -731,36 +731,6 @@ sec_to_styp_flags (const char *sec_name, flagword sec_flags)
|
|||||||
|
|
||||||
#ifndef COFF_WITH_PE
|
#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
|
static bool
|
||||||
styp_to_sec_flags (bfd *abfd,
|
styp_to_sec_flags (bfd *abfd,
|
||||||
void * hdr,
|
void * hdr,
|
||||||
@ -2185,11 +2155,6 @@ coff_mkobject_hook (bfd * abfd,
|
|||||||
abfd->flags |= HAS_DEBUG;
|
abfd->flags |= HAS_DEBUG;
|
||||||
#endif
|
#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;
|
return coff;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -356,6 +356,21 @@ coff_object_p (bfd *abfd)
|
|||||||
: (struct internal_aouthdr *) NULL));
|
: (struct internal_aouthdr *) NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
/* Get the BFD section from a COFF symbol section number. */
|
/* Get the BFD section from a COFF symbol section number. */
|
||||||
|
|
||||||
asection *
|
asection *
|
||||||
@ -371,17 +386,23 @@ coff_section_from_bfd_index (bfd *abfd, int section_index)
|
|||||||
struct bfd_section *answer;
|
struct bfd_section *answer;
|
||||||
htab_t table = coff_data (abfd)->section_by_target_index;
|
htab_t table = coff_data (abfd)->section_by_target_index;
|
||||||
|
|
||||||
|
if (!table)
|
||||||
|
{
|
||||||
|
table = htab_create (10, htab_hash_section_target_index,
|
||||||
|
htab_eq_section_target_index, NULL);
|
||||||
|
if (table == NULL)
|
||||||
|
return bfd_und_section_ptr;
|
||||||
|
coff_data (abfd)->section_by_target_index = table;
|
||||||
|
}
|
||||||
|
|
||||||
if (htab_elements (table) == 0)
|
if (htab_elements (table) == 0)
|
||||||
{
|
{
|
||||||
answer = abfd->sections;
|
for (answer = abfd->sections; answer; answer = answer->next)
|
||||||
|
|
||||||
while (answer)
|
|
||||||
{
|
{
|
||||||
void **slot = htab_find_slot (table, answer, INSERT);
|
void **slot = htab_find_slot (table, answer, INSERT);
|
||||||
if (slot == NULL)
|
if (slot == NULL)
|
||||||
return bfd_und_section_ptr;
|
return bfd_und_section_ptr;
|
||||||
*slot = answer;
|
*slot = answer;
|
||||||
answer = answer->next;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,14 +413,16 @@ coff_section_from_bfd_index (bfd *abfd, int section_index)
|
|||||||
if (answer != NULL)
|
if (answer != NULL)
|
||||||
return answer;
|
return answer;
|
||||||
|
|
||||||
answer = abfd->sections;
|
/* Cover the unlikely case of sections added after the first call to
|
||||||
|
this function. */
|
||||||
while (answer)
|
for (answer = abfd->sections; answer; answer = answer->next)
|
||||||
{
|
if (answer->target_index == section_index)
|
||||||
if (answer->target_index == section_index)
|
{
|
||||||
|
void **slot = htab_find_slot (table, answer, INSERT);
|
||||||
|
if (slot != NULL)
|
||||||
|
*slot = answer;
|
||||||
return answer;
|
return answer;
|
||||||
answer = answer->next;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* We should not reach this point, but the SCO 3.2v4 /lib/libc_s.a
|
/* We should not reach this point, but the SCO 3.2v4 /lib/libc_s.a
|
||||||
has a bad symbol table in biglitpow.o. */
|
has a bad symbol table in biglitpow.o. */
|
||||||
|
@ -255,36 +255,6 @@ coff_swap_scnhdr_in (bfd * abfd, void * ext, void * in)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
static bool
|
||||||
pe_mkobject (bfd * abfd)
|
pe_mkobject (bfd * abfd)
|
||||||
{
|
{
|
||||||
@ -382,11 +352,6 @@ pe_mkobject_hook (bfd * abfd,
|
|||||||
memcpy (pe->dos_message, internal_f->pe.dos_message,
|
memcpy (pe->dos_message, internal_f->pe.dos_message,
|
||||||
sizeof (pe->dos_message));
|
sizeof (pe->dos_message));
|
||||||
|
|
||||||
pe->coff.section_by_index
|
|
||||||
= htab_create (10, htab_hash_section_index, htab_eq_section_index, NULL);
|
|
||||||
pe->coff.section_by_target_index = htab_create
|
|
||||||
(10, htab_hash_section_target_index, htab_eq_section_target_index, NULL);
|
|
||||||
|
|
||||||
return (void *) pe;
|
return (void *) pe;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user