diff --git a/bfd/elf.c b/bfd/elf.c index db45d1a074b..02246b1360c 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -2928,6 +2928,44 @@ bfd_section_from_shdr (bfd *abfd, unsigned int shindex) goto success; } + /* Check to make sure that the target supports this type of relocation. + Note - we do not treat lack of support as a failure, since we may + just be displaying information from an experimental file that is + using an unexpected relocation type. Plus if we 'goto fail' here + our error message will be suppressed by the format matching code. + Instead we tell the users that they might not be getting the + results that they expect. */ + static bool already_warned = false; /* Only warn once. */ + if (! already_warned) + { + bool supported; + const char * rel_name; + + switch (hdr->sh_type) + { + case SHT_REL: + supported = get_elf_backend_data (abfd)->may_use_rel_p; + rel_name = "REL"; + break; + + case SHT_RELA: + supported = get_elf_backend_data (abfd)->may_use_rela_p; + rel_name = "RELA"; + break; + + default: + supported = true; + } + + if (! supported) + { + /* xgettext:c-format */ + _bfd_error_handler (_("%pB: Warning: %s type relocations are not expected for architecture '%s' - supprt may be incomplete"), + abfd, rel_name, bfd_printable_name (abfd)); + already_warned = true; + } + } + /* Get the symbol table. */ if ((elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_SYMTAB || elf_elfsections (abfd)[hdr->sh_link]->sh_type == SHT_DYNSYM)