forked from Imagelibrary/binutils-gdb
PR30198, Assertion and segfault when linking x86_64 elf and coff
PR 30198 * coff-x86_64.c (coff_amd64_reloc): Set *error_message when returning bfd_reloc_dangerous. Also check that __ImageBase is defined before accessing h->u.def.
This commit is contained in:
@@ -139,15 +139,19 @@ coff_amd64_reloc (bfd *abfd,
|
|||||||
break;
|
break;
|
||||||
case bfd_target_elf_flavour:
|
case bfd_target_elf_flavour:
|
||||||
/* Subtract __ImageBase. */
|
/* Subtract __ImageBase. */
|
||||||
|
h = NULL;
|
||||||
link_info = _bfd_get_link_info (obfd);
|
link_info = _bfd_get_link_info (obfd);
|
||||||
if (link_info == NULL)
|
if (link_info != NULL)
|
||||||
return bfd_reloc_dangerous;
|
h = bfd_link_hash_lookup (link_info->hash, "__ImageBase",
|
||||||
h = bfd_link_hash_lookup (link_info->hash, "__ImageBase",
|
false, false, true);
|
||||||
false, false, false);
|
if (h == NULL
|
||||||
if (h == NULL)
|
|| (h->type != bfd_link_hash_defined
|
||||||
return bfd_reloc_dangerous;
|
&& h->type != bfd_link_hash_defweak))
|
||||||
while (h->type == bfd_link_hash_indirect)
|
{
|
||||||
h = h->u.i.link;
|
*error_message
|
||||||
|
= (char *) _("R_AMD64_IMAGEBASE with __ImageBase undefined");
|
||||||
|
return bfd_reloc_dangerous;
|
||||||
|
}
|
||||||
/* ELF symbols in relocatable files are section relative,
|
/* ELF symbols in relocatable files are section relative,
|
||||||
but in nonrelocatable files they are virtual addresses. */
|
but in nonrelocatable files they are virtual addresses. */
|
||||||
diff -= (h->u.def.value
|
diff -= (h->u.def.value
|
||||||
|
|||||||
Reference in New Issue
Block a user