aboutsummaryrefslogtreecommitdiff
path: root/bfd/elf64-mmix.c
diff options
context:
space:
mode:
authorHans-Peter Nilsson <hp@bitrange.com>2017-07-25 04:09:32 +0200
committerHans-Peter Nilsson <hp@bitrange.com>2017-08-21 03:43:35 +0200
commit284d826d9f57e3ff47e41f61f3250c8d029baaa3 (patch)
treeb6ff8464f39f8dc7a92634e0d4e83c193354f243 /bfd/elf64-mmix.c
parent454c9bb956abd5451b6a46c96327c5ec0884eaed (diff)
downloadgdb-284d826d9f57e3ff47e41f61f3250c8d029baaa3.zip
gdb-284d826d9f57e3ff47e41f61f3250c8d029baaa3.tar.gz
gdb-284d826d9f57e3ff47e41f61f3250c8d029baaa3.tar.bz2
PR ld/20125, MMIX weak symbols
Weak undefineds with PUSHJ relocs were "lost", causing internal inconsistencies and an abort.
Diffstat (limited to 'bfd/elf64-mmix.c')
-rw-r--r--bfd/elf64-mmix.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/bfd/elf64-mmix.c b/bfd/elf64-mmix.c
index 8c8e06d..8d79d39 100644
--- a/bfd/elf64-mmix.c
+++ b/bfd/elf64-mmix.c
@@ -2710,8 +2710,21 @@ mmix_elf_relax_section (bfd *abfd,
indx = ELF64_R_SYM (irel->r_info) - symtab_hdr->sh_info;
h = elf_sym_hashes (abfd)[indx];
BFD_ASSERT (h != NULL);
- if (h->root.type != bfd_link_hash_defined
- && h->root.type != bfd_link_hash_defweak)
+ if (h->root.type == bfd_link_hash_undefweak)
+ /* FIXME: for R_MMIX_PUSHJ_STUBBABLE, there are alternatives to
+ the canonical value 0 for an unresolved weak symbol to
+ consider: as the debug-friendly approach, resolve to "abort"
+ (or a port-specific function), or as the space-friendly
+ approach resolve to the next instruction (like some other
+ ports, notably ARM and AArch64). These alternatives require
+ matching code in mmix_elf_perform_relocation or its caller. */
+ symval = 0;
+ else if (h->root.type == bfd_link_hash_defined
+ || h->root.type == bfd_link_hash_defweak)
+ symval = (h->root.u.def.value
+ + h->root.u.def.section->output_section->vma
+ + h->root.u.def.section->output_offset);
+ else
{
/* This appears to be a reference to an undefined symbol. Just
ignore it--it will be caught by the regular reloc processing.
@@ -2725,10 +2738,6 @@ mmix_elf_relax_section (bfd *abfd,
}
continue;
}
-
- symval = (h->root.u.def.value
- + h->root.u.def.section->output_section->vma
- + h->root.u.def.section->output_offset);
}
if (ELF64_R_TYPE (irel->r_info) == (int) R_MMIX_PUSHJ_STUBBABLE)
@@ -2866,6 +2875,8 @@ mmix_elf_relax_section (bfd *abfd,
}
}
+ BFD_ASSERT(pjsno == mmix_elf_section_data (sec)->pjs.n_pushj_relocs);
+
if (internal_relocs != NULL
&& elf_section_data (sec)->relocs != internal_relocs)
free (internal_relocs);