* elflink.h (elf_link_input_bfd): Complain about all relocs

against local syms from discarded sections.
	(elf_reloc_symbol_deleted_p): Don't try to swap in external syms.
This commit is contained in:
Alan Modra
2001-11-15 09:31:25 +00:00
parent 33861b119a
commit f9f32305f7
2 changed files with 49 additions and 48 deletions

View File

@ -1,3 +1,10 @@
2001-11-15 Alan Modra <amodra@bigpond.net.au>
* elflink.h (elf_link_input_bfd): Complain about all relocs
against local syms from discarded sections. K&R fixes.
(elf_reloc_symbol_deleted_p): Don't try to swap in external syms.
K&R fixes.
2001-11-15 Alexandre Oliva <aoliva@redhat.com> 2001-11-15 Alexandre Oliva <aoliva@redhat.com>
* elf64-sparc.c (sparc64_elf_relocate_section): Disregard * elf64-sparc.c (sparc64_elf_relocate_section): Disregard

View File

@ -6343,53 +6343,49 @@ elf_link_input_bfd (finfo, input_bfd)
} }
else else
{ {
isym = finfo->internal_syms + r_symndx; asection *sec = finfo->sections[r_symndx];
if (ELF_ST_TYPE (isym->st_info) == STT_SECTION)
if (sec != NULL
&& ! bfd_is_abs_section (sec)
&& bfd_is_abs_section (sec->output_section))
{ {
asection *sec = finfo->sections[r_symndx];
if (sec != NULL
&& ! bfd_is_abs_section (sec)
&& bfd_is_abs_section (sec->output_section))
{
#if BFD_VERSION_DATE < 20031005 #if BFD_VERSION_DATE < 20031005
if ((o->flags & SEC_DEBUGGING) != 0 if ((o->flags & SEC_DEBUGGING) != 0
|| (sec->flags & SEC_LINK_ONCE) != 0) || (sec->flags & SEC_LINK_ONCE) != 0)
{ {
#if BFD_VERSION_DATE > 20021005 #if BFD_VERSION_DATE > 20021005
(*finfo->info->callbacks->warning) (*finfo->info->callbacks->warning)
(finfo->info, (finfo->info,
_("warning: relocation against removed section"), _("warning: relocation against removed section"),
NULL, input_bfd, o, rel->r_offset); NULL, input_bfd, o, rel->r_offset);
#endif #endif
rel->r_info rel->r_info
= ELF_R_INFO (0, ELF_R_TYPE (rel->r_info)); = ELF_R_INFO (0, ELF_R_TYPE (rel->r_info));
rel->r_addend = 0; rel->r_addend = 0;
} }
else else
#endif #endif
{ {
boolean ok; boolean ok;
const char *msg const char *msg
= _("local symbols in discarded section %s"); = _("local symbols in discarded section %s");
bfd_size_type amt bfd_size_type amt
= strlen (sec->name) + strlen (msg) - 1; = strlen (sec->name) + strlen (msg) - 1;
char *buf = (char *) bfd_malloc (amt); char *buf = (char *) bfd_malloc (amt);
if (buf != NULL) if (buf != NULL)
sprintf (buf, msg, sec->name); sprintf (buf, msg, sec->name);
else else
buf = (char *) sec->name; buf = (char *) sec->name;
ok = (*finfo->info->callbacks ok = (*finfo->info->callbacks
->undefined_symbol) (finfo->info, buf, ->undefined_symbol) (finfo->info, buf,
input_bfd, o, input_bfd, o,
rel->r_offset, rel->r_offset,
true); true);
if (buf != sec->name) if (buf != sec->name)
free (buf); free (buf);
if (!ok) if (!ok)
return false; return false;
}
} }
} }
} }
@ -6595,7 +6591,7 @@ elf_link_input_bfd (finfo, input_bfd)
/* Write out the modified section contents. */ /* Write out the modified section contents. */
if (bed->elf_backend_write_section if (bed->elf_backend_write_section
&& bed->elf_backend_write_section (output_bfd, o, contents)) && (*bed->elf_backend_write_section) (output_bfd, o, contents))
{ {
/* Section written out. */ /* Section written out. */
} }
@ -7786,9 +7782,9 @@ elf_reloc_symbol_deleted_p (offset, cookie)
if (rcookie->rel->r_offset != offset) if (rcookie->rel->r_offset != offset)
continue; continue;
if (rcookie->locsyms) if (rcookie->locsyms && r_symndx < rcookie->locsymcount)
elf_swap_symbol_in (rcookie->abfd, elf_swap_symbol_in (rcookie->abfd,
((Elf_External_Sym *)rcookie->locsyms) + r_symndx, (Elf_External_Sym *) rcookie->locsyms + r_symndx,
&isym); &isym);
if (r_symndx >= rcookie->locsymcount if (r_symndx >= rcookie->locsymcount
@ -7953,11 +7949,9 @@ elf_section_ignore_discarded_relocs (sec)
return true; return true;
else if ((get_elf_backend_data (sec->owner) else if ((get_elf_backend_data (sec->owner)
->elf_backend_ignore_discarded_relocs != NULL) ->elf_backend_ignore_discarded_relocs != NULL)
&& (get_elf_backend_data (sec->owner) && (*get_elf_backend_data (sec->owner)
->elf_backend_ignore_discarded_relocs (sec))) ->elf_backend_ignore_discarded_relocs) (sec))
return true; return true;
else else
return false; return false;
} }