+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>
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;
+}
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;
}
}
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;
}
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;
}
}
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
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
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;
const char *functionname;
unsigned int linenumber;
bfd_boolean discard_last;
+ char *sec_name;
abfd = va_arg (arg, bfd *);
section = va_arg (arg, asection *);
}
}
- lfinfo (fp, "%B(%s+0x%v)", abfd, section->name, offset);
+ sec_name = bfd_get_section_ident (section);
+ lfinfo (fp, "%B(%s+0x%v)", abfd,
+ sec_name ? sec_name : section->name, offset);
+ if (sec_name)
+ free (sec_name);
discard_last = TRUE;
if (bfd_find_nearest_line (abfd, section, asymbols, offset,