2004-05-02  H.J. Lu  <hongjiu.lu@intel.com>

	* section.c (bfd_get_section_by_name_if): New.
	* bfd-in2.h: Regenerated.

gas/

2004-05-02  H.J. Lu  <hongjiu.lu@intel.com>

	* config/obj-elf.c (get_section): Return bfd_boolean.
	(obj_elf_change_section): Call bfd_get_section_by_name_if
	instead of bfd_map_over_sections.
This commit is contained in:
H.J. Lu
2004-05-02 14:36:25 +00:00
parent eb4556d736
commit fafe6678a5
5 changed files with 84 additions and 36 deletions

View File

@@ -799,6 +799,57 @@ bfd_get_section_by_name (bfd *abfd, const char *name)
return NULL;
}
/*
FUNCTION
bfd_get_section_by_name_if
SYNOPSIS
asection *bfd_get_section_by_name_if
(bfd *abfd,
const char *name,
bfd_boolean (*func) (bfd *abfd, asection *sect, void *obj),
void *obj);
DESCRIPTION
Call the provided function @var{func} for each section
attached to the BFD @var{abfd} whose name matches @var{name},
passing @var{obj} as an argument. The function will be called
as if by
| func (abfd, the_section, obj);
It returns the first section for which @var{func} returns true,
otherwise <<NULL>>.
*/
asection *
bfd_get_section_by_name_if (bfd *abfd, const char *name,
bfd_boolean (*operation) (bfd *,
asection *,
void *),
void *user_storage)
{
struct section_hash_entry *sh;
unsigned long hash;
sh = section_hash_lookup (&abfd->section_htab, name, FALSE, FALSE);
if (sh == NULL)
return NULL;
hash = sh->root.hash;
do
{
if ((*operation) (abfd, &sh->section, user_storage))
return &sh->section;
sh = (struct section_hash_entry *) sh->root.next;
}
while (sh != NULL && sh->root.hash == hash
&& strcmp (sh->root.string, name) == 0);
return NULL;
}
/*
FUNCTION
bfd_get_unique_section_name