summaryrefslogtreecommitdiff
path: root/bfd/bfd.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl@lucon.org>2004-07-02 01:39:31 +0000
committerH.J. Lu <hjl@lucon.org>2004-07-02 01:39:31 +0000
commite875e9faff25832a8a4aa1b5b0665c50e0afb50a (patch)
treeaef8389bae9edf79141bf330b6cf13ab6335fb7b /bfd/bfd.c
parente70726b726df541edc5d752f2699c2bd05fc9966 (diff)
downloadgdb-e875e9faff25832a8a4aa1b5b0665c50e0afb50a.tar.gz
bfd/
2004-07-01 H.J. Lu <hongjiu.lu@intel.com> * bfd.c (bfd_get_section_ident): New. * elflink.c (elf_link_read_relocs_from_section): Call bfd_get_section_ident to identify the section when reporting error. (_bfd_elf_link_output_relocs): Likewise. (elf_link_output_extsym): Likewise. (elf_link_input_bfd): Likewise. (bfd_elf_gc_record_vtinherit): Likewise. * bfd-in2.h: Regenerated. ld/ 2004-07-01 H.J. Lu <hongjiu.lu@intel.com> * ldmisc.c (vfinfo): Call bfd_get_section_ident to identify the section.
Diffstat (limited to 'bfd/bfd.c')
-rw-r--r--bfd/bfd.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/bfd/bfd.c b/bfd/bfd.c
index 3ead0ee5b5a..209b1b681a7 100644
--- a/bfd/bfd.c
+++ b/bfd/bfd.c
@@ -1417,3 +1417,46 @@ bfd_preserve_finish (bfd *abfd ATTRIBUTE_UNUSED, struct bfd_preserve *preserve)
objalloc. */
bfd_hash_table_free (&preserve->section_htab);
}
+
+/*
+FUNCTION
+ bfd_get_section_ident
+
+SYNOPSIS
+ char *bfd_get_section_ident (asection *sec);
+
+DESCRIPTION
+ This function returns "section name[group name]" in a malloced
+ buffer if @var{sec} is a member of an ELF section group and
+ returns NULL otherwise. The caller should free the non-NULL
+ return after use.
+
+*/
+
+char *
+bfd_get_section_ident (asection *sec)
+{
+ char *buf;
+ bfd_size_type nlen;
+ bfd_size_type glen;
+
+ if (sec->owner == NULL
+ || bfd_get_flavour (sec->owner) != bfd_target_elf_flavour
+ || elf_next_in_group (sec) == NULL
+ || (sec->flags & SEC_GROUP) != 0)
+ return NULL;
+
+ nlen = strlen (sec->name);
+ glen = strlen (elf_group_name (sec));
+ buf = bfd_malloc (nlen + glen + 2 + 1);
+ if (buf != NULL)
+ {
+ strcpy (buf, sec->name);
+ buf [nlen] = '[';
+ strcpy (&buf [nlen + 1], elf_group_name (sec));
+ buf [nlen + 1 + glen] = ']';
+ buf [nlen + 1 + glen + 1] = '\0';
+ }
+
+ return buf;
+}