forked from Imagelibrary/binutils-gdb
bfd/ChangeLog:
PR ld/12365 * cofflink.c (bfd_coff_link_input_bfd): Check for and warn about references to symbols defined in discarded sections. ld/ChangeLog: PR ld/12365 * scripttempl/pe.sc (__rt_psrelocs_start): New symbol definition. (__rt_psrelocs_end): Likewise. (__rt_psrelocs_size): Likewise difference between the above. (__RUNTIME_PSEUDO_RELOC_LIST_END__): Move outside .rdata section immediately after end of pseudo-reloc data. (___RUNTIME_PSEUDO_RELOC_LIST_END___): Likewise. (__RUNTIME_PSEUDO_RELOC_LIST__): Move outside .rdata section and calculate backward from list end. (___RUNTIME_PSEUDO_RELOC_LIST___): Likewise. * scripttempl/pep.sc: Likewise. ld/testsuite/ChangeLog: PR ld/12365 * ld-plugin/plugin-7.d: Allow underscore in error message. * ld-plugin/plugin-8.d: Likewise.
This commit is contained in:
@@ -2365,6 +2365,35 @@ _bfd_coff_link_input_bfd (struct coff_final_link_info *finfo, bfd *input_bfd)
|
||||
if (internal_relocs == NULL)
|
||||
return FALSE;
|
||||
|
||||
/* Run through the relocs looking for relocs against symbols
|
||||
coming from discarded sections and complain about them. */
|
||||
irel = internal_relocs;
|
||||
for (; irel < &internal_relocs[o->reloc_count]; irel++)
|
||||
{
|
||||
struct coff_link_hash_entry *h;
|
||||
asection *ps = NULL;
|
||||
long symndx = irel->r_symndx;
|
||||
if (symndx < 0)
|
||||
continue;
|
||||
h = obj_coff_sym_hashes (input_bfd)[symndx];
|
||||
if (h == NULL)
|
||||
continue;
|
||||
while (h->root.type == bfd_link_hash_indirect
|
||||
|| h->root.type == bfd_link_hash_warning)
|
||||
h = (struct coff_link_hash_entry *) h->root.u.i.link;
|
||||
if (h->root.type == bfd_link_hash_defined
|
||||
|| h->root.type == bfd_link_hash_defweak)
|
||||
ps = h->root.u.def.section;
|
||||
if (ps == NULL)
|
||||
continue;
|
||||
/* Complain if definition comes from an excluded section. */
|
||||
if (ps->flags & SEC_EXCLUDE)
|
||||
(*finfo->info->callbacks->einfo)
|
||||
(_("%X`%s' referenced in section `%A' of %B: "
|
||||
"defined in discarded section `%A' of %B\n"),
|
||||
h->root.root.string, o, input_bfd, ps, ps->owner);
|
||||
}
|
||||
|
||||
/* Call processor specific code to relocate the section
|
||||
contents. */
|
||||
if (! bfd_coff_relocate_section (output_bfd, finfo->info,
|
||||
|
||||
Reference in New Issue
Block a user