aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2004-05-02 14:36:25 +0000
committerH.J. Lu <hjl.tools@gmail.com>2004-05-02 14:36:25 +0000
commitfafe6678a56d703ba0d3bfc32ff12f99b979f339 (patch)
tree7eff8f48c45bf21a28b8b12c78358aa92d9d1255 /bfd
parenteb4556d736ee14965782a320db1496fb070e54c3 (diff)
downloadgdb-fafe6678a56d703ba0d3bfc32ff12f99b979f339.zip
gdb-fafe6678a56d703ba0d3bfc32ff12f99b979f339.tar.gz
gdb-fafe6678a56d703ba0d3bfc32ff12f99b979f339.tar.bz2
bfd/
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.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog5
-rw-r--r--bfd/bfd-in2.h6
-rw-r--r--bfd/section.c51
3 files changed, 62 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 875fcd2..b5e5523 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2004-05-02 H.J. Lu <hongjiu.lu@intel.com>
+
+ * section.c (bfd_get_section_by_name_if): New.
+ * bfd-in2.h: Regenerated.
+
2004-05-02 Alan Modra <amodra@bigpond.net.au>
* som.c (som_bfd_is_group_section): Define.
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 5843a19..c246356 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -1433,6 +1433,12 @@ void bfd_section_list_clear (bfd *);
asection *bfd_get_section_by_name (bfd *abfd, const char *name);
+asection *bfd_get_section_by_name_if
+ (bfd *abfd,
+ const char *name,
+ bfd_boolean (*func) (bfd *abfd, asection *sect, void *obj),
+ void *obj);
+
char *bfd_get_unique_section_name
(bfd *abfd, const char *templat, int *count);
diff --git a/bfd/section.c b/bfd/section.c
index 58508a2..7f5365b 100644
--- a/bfd/section.c
+++ b/bfd/section.c
@@ -801,6 +801,57 @@ bfd_get_section_by_name (bfd *abfd, const char *name)
/*
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
SYNOPSIS