This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Patch: Use is_elf_hash_table() to check the type of a hash table ina bfd_link_info structure
- From: Nick Clifton <nickc at redhat dot com>
- To: binutils at sources dot redhat dot com
- Date: Wed, 21 May 2003 10:11:42 +0100
- Subject: Patch: Use is_elf_hash_table() to check the type of a hash table ina bfd_link_info structure
Hi Guys,
I am applying the patch below to fix a bug in
bfd_elf_get_needed_list() exposed by running the linker test suite
for the i960-elf toolchain.
Under some circumstances it is possible that the bfd_link_info
structure passed to this function to have a generic
bfd_link_hash_table structure not an elf_link_hash_table structure.
This is despite the fact that the creator field points to an elf
flavoured target. This can cause the function to attempt to access
the 'needed' field of a structure that isn't there.
A similar problem applies to the bfd_elf_get_dt_soname() function.
The fix is to use the is_elf_hash_table() function instead of
checking the hash table's creator's flavour.
Daniel - shall I apply this patch to the branch ?
Cheers
Nick
2003-05-21 Nick Clifton <nickc@redhat.com>
* elf.c (bfd_elf_get_needed_list): Use is_elf_hash_table to check
the type of the has table in the bfd_link_info structure.
(bfd_elf_get_runpath_list): Likewise.
Index: bfd/elf.c
===================================================================
RCS file: /cvs/src/src/bfd/elf.c,v
retrieving revision 1.186
diff -c -3 -p -w -r1.186 elf.c
*** bfd/elf.c 21 May 2003 00:56:00 -0000 1.186
--- bfd/elf.c 21 May 2003 09:18:47 -0000
*************** bfd_elf_get_needed_list (abfd, info)
*** 1616,1622 ****
bfd *abfd ATTRIBUTE_UNUSED;
struct bfd_link_info *info;
{
! if (info->hash->creator->flavour != bfd_target_elf_flavour)
return NULL;
return elf_hash_table (info)->needed;
}
--- 1616,1622 ----
bfd *abfd ATTRIBUTE_UNUSED;
struct bfd_link_info *info;
{
! if (! is_elf_hash_table (info))
return NULL;
return elf_hash_table (info)->needed;
}
*************** bfd_elf_get_runpath_list (abfd, info)
*** 1629,1635 ****
bfd *abfd ATTRIBUTE_UNUSED;
struct bfd_link_info *info;
{
! if (info->hash->creator->flavour != bfd_target_elf_flavour)
return NULL;
return elf_hash_table (info)->runpath;
}
--- 1629,1635 ----
bfd *abfd ATTRIBUTE_UNUSED;
struct bfd_link_info *info;
{
! if (! is_elf_hash_table (info))
return NULL;
return elf_hash_table (info)->runpath;
}