aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2004-07-02 01:39:32 +0000
committerH.J. Lu <hjl.tools@gmail.com>2004-07-02 01:39:32 +0000
commitb602c853d891e7b7885058bff76a796c2e47b42e (patch)
tree9909bc2499c111a7e8b20d5f6a2fbd27734fd99e /bfd
parentac6b4428da2f037bd99718e5594a626cab6d1a47 (diff)
downloadgdb-b602c853d891e7b7885058bff76a796c2e47b42e.zip
gdb-b602c853d891e7b7885058bff76a796c2e47b42e.tar.gz
gdb-b602c853d891e7b7885058bff76a796c2e47b42e.tar.bz2
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')
-rw-r--r--bfd/ChangeLog14
-rw-r--r--bfd/bfd-in2.h2
-rw-r--r--bfd/bfd.c43
-rw-r--r--bfd/elflink.c35
4 files changed, 87 insertions, 7 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index fdd44e7..dc07cc1 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,17 @@
+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.
+
2004-07-01 Jie Zhang <zhangjie@magima.com.cn>
Nick Clifton <nickc@redhat.com>
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 7335774..9072d95 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -4090,6 +4090,8 @@ void bfd_preserve_restore (bfd *, struct bfd_preserve *);
void bfd_preserve_finish (bfd *, struct bfd_preserve *);
+char *bfd_get_section_ident (asection *sec);
+
/* Extracted from archive.c. */
symindex bfd_get_next_mapent
(bfd *abfd, symindex previous, carsym **sym);
diff --git a/bfd/bfd.c b/bfd/bfd.c
index 3ead0ee..209b1b6 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;
+}
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 930438d..c2830ff 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -1859,10 +1859,14 @@ elf_link_read_relocs_from_section (bfd *abfd,
r_symndx >>= 24;
if ((size_t) r_symndx >= nsyms)
{
+ char *sec_name = bfd_get_section_ident (sec);
(*_bfd_error_handler)
(_("%s: bad reloc symbol index (0x%lx >= 0x%lx) for offset 0x%lx in section `%s'"),
bfd_archive_filename (abfd), (unsigned long) r_symndx,
- (unsigned long) nsyms, irela->r_offset, sec->name);
+ (unsigned long) nsyms, irela->r_offset,
+ sec_name ? sec_name : sec->name);
+ if (sec_name)
+ free (sec_name);
bfd_set_error (bfd_error_bad_value);
return FALSE;
}
@@ -2048,11 +2052,14 @@ _bfd_elf_link_output_relocs (bfd *output_bfd,
}
else
{
+ char *sec_name = bfd_get_section_ident (input_section);
(*_bfd_error_handler)
(_("%s: relocation size mismatch in %s section %s"),
bfd_get_filename (output_bfd),
bfd_archive_filename (input_section->owner),
- input_section->name);
+ sec_name ? sec_name : input_section->name);
+ if (sec_name)
+ free (sec_name);
bfd_set_error (bfd_error_wrong_object_format);
return FALSE;
}
@@ -6073,11 +6080,14 @@ elf_link_output_extsym (struct elf_link_hash_entry *h, void *data)
input_sec->output_section);
if (sym.st_shndx == SHN_BAD)
{
+ char *sec_name = bfd_get_section_ident (input_sec);
(*_bfd_error_handler)
(_("%s: could not find output section %s for input section %s"),
bfd_get_filename (finfo->output_bfd),
input_sec->output_section->name,
- input_sec->name);
+ sec_name ? sec_name : input_sec->name);
+ if (sec_name)
+ free (sec_name);
eoinfo->failed = TRUE;
return FALSE;
}
@@ -6638,13 +6648,21 @@ elf_link_input_bfd (struct elf_final_link_info *finfo, bfd *input_bfd)
}
else if (complain)
{
+ char *r_sec
+ = bfd_get_section_ident (o);
+ char *d_sec
+ = bfd_get_section_ident (sec);
finfo->info->callbacks->error_handler
(LD_DEFINITION_IN_DISCARDED_SECTION,
_("`%T' referenced in section `%s' of %B: "
"defined in discarded section `%s' of %B\n"),
- sym_name,
- sym_name, o->name, input_bfd,
- sec->name, sec->owner);
+ sym_name, sym_name,
+ r_sec ? r_sec : o->name, input_bfd,
+ d_sec ? d_sec : sec->name, sec->owner);
+ if (r_sec)
+ free (r_sec);
+ if (d_sec)
+ free (d_sec);
}
/* Remove the symbol reference from the reloc, but
@@ -8567,6 +8585,7 @@ bfd_elf_gc_record_vtinherit (bfd *abfd,
struct elf_link_hash_entry **search, *child;
bfd_size_type extsymcount;
const struct elf_backend_data *bed = get_elf_backend_data (abfd);
+ char *sec_name;
/* The sh_info field of the symtab header tells us where the
external symbols start. We don't care about the local symbols at
@@ -8590,8 +8609,10 @@ bfd_elf_gc_record_vtinherit (bfd *abfd,
goto win;
}
+ sec_name = bfd_get_section_ident (sec);
(*_bfd_error_handler) ("%s: %s+%lu: No symbol found for INHERIT",
- bfd_archive_filename (abfd), sec->name,
+ bfd_archive_filename (abfd),
+ sec_name ? sec_name : sec->name,
(unsigned long) offset);
bfd_set_error (bfd_error_invalid_operation);
return FALSE;