summaryrefslogtreecommitdiff
path: root/bfd/section.c
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2012-05-22 12:09:24 +0000
committerAlan Modra <amodra@bigpond.net.au>2012-05-22 12:09:24 +0000
commit5f031c564ce24a6f68614802fee6e742d653a46e (patch)
tree377d10878069ba382f2b8d640d932a8ea7d7c059 /bfd/section.c
parent75baece206bad1195fbf3e8cdaaa9e7eaa7aa908 (diff)
downloadbinutils-redhat-5f031c564ce24a6f68614802fee6e742d653a46e.tar.gz
* elflink.c (bfd_elf_discard_info): Handle multiple .eh_frame
sections attached to a BFD. * section.c (bfd_get_section_by_name): Rewrite description. (bfd_get_next_section_by_name): New function. * bfd-in2.h: Regenerate.
Diffstat (limited to 'bfd/section.c')
-rw-r--r--bfd/section.c45
1 files changed, 37 insertions, 8 deletions
diff --git a/bfd/section.c b/bfd/section.c
index 3a70ccf994..0a7908e1f6 100644
--- a/bfd/section.c
+++ b/bfd/section.c
@@ -845,14 +845,8 @@ SYNOPSIS
asection *bfd_get_section_by_name (bfd *abfd, const char *name);
DESCRIPTION
- Run through @var{abfd} and return the one of the
- <<asection>>s whose name matches @var{name}, otherwise <<NULL>>.
- @xref{Sections}, for more information.
-
- This should only be used in special cases; the normal way to process
- all sections of a given name is to use <<bfd_map_over_sections>> and
- <<strcmp>> on the name (or better yet, base it on the section flags
- or something else) for each section.
+ Return the most recently created section attached to @var{abfd}
+ named @var{name}. Return NULL if no such section exists.
*/
asection *
@@ -869,6 +863,41 @@ bfd_get_section_by_name (bfd *abfd, const char *name)
/*
FUNCTION
+ bfd_get_next_section_by_name
+
+SYNOPSIS
+ asection *bfd_get_next_section_by_name (asection *sec);
+
+DESCRIPTION
+ Given @var{sec} is a section returned by @code{bfd_get_section_by_name},
+ return the next most recently created section attached to the same
+ BFD with the same name. Return NULL if no such section exists.
+*/
+
+asection *
+bfd_get_next_section_by_name (asection *sec)
+{
+ struct section_hash_entry *sh;
+ const char *name;
+ unsigned long hash;
+
+ sh = ((struct section_hash_entry *)
+ ((char *) sec - offsetof (struct section_hash_entry, section)));
+
+ hash = sh->root.hash;
+ name = sec->name;
+ for (sh = (struct section_hash_entry *) sh->root.next;
+ sh != NULL;
+ sh = (struct section_hash_entry *) sh->root.next)
+ if (sh->root.hash == hash
+ && strcmp (sh->root.string, name) == 0)
+ return &sh->section;
+
+ return NULL;
+}
+
+/*
+FUNCTION
bfd_get_section_by_name_if
SYNOPSIS