From 9435372041a8824deb18a9225e6817b61c7afc6b Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Fri, 11 Feb 2005 22:29:10 +0000 Subject: [PATCH] * elf32-mips.c (_bfd_mips_elf32_gprel16_reloc): Reject R_MIPS_LITERAL relocations for external symbols. * elf64-mips.c (mips_elf64_literal_reloc): Likewise. * elfn32-mips.c (mips_elf_literal_reloc): Likewise. --- bfd/ChangeLog | 7 +++++++ bfd/elf32-mips.c | 11 +++++++++++ bfd/elf64-mips.c | 8 ++++---- bfd/elfn32-mips.c | 10 ++++++++++ 4 files changed, 32 insertions(+), 4 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 17fe6e6e6..89ca22a91 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2005-02-11 Maciej W. Rozycki + + * elf32-mips.c (_bfd_mips_elf32_gprel16_reloc): Reject + R_MIPS_LITERAL relocations for external symbols. + * elf64-mips.c (mips_elf64_literal_reloc): Likewise. + * elfn32-mips.c (mips_elf_literal_reloc): Likewise. + 2005-02-11 H.J. Lu * bfd-in2.h: Rebuilt. diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index 07d8ba4b5..5c259f101 100644 --- a/bfd/elf32-mips.c +++ b/bfd/elf32-mips.c @@ -770,6 +770,17 @@ _bfd_mips_elf32_gprel16_reloc (bfd *abfd, arelent *reloc_entry, bfd_reloc_status_type ret; bfd_vma gp; + /* R_MIPS_LITERAL relocations are defined for local symbols only. */ + if (reloc_entry->howto->type == R_MIPS_LITERAL + && output_bfd != NULL + && (symbol->flags & BSF_SECTION_SYM) == 0 + && (symbol->flags & BSF_LOCAL) != 0) + { + *error_message = (char *) + _("literal relocation occurs for an external symbol"); + return bfd_reloc_outofrange; + } + if (output_bfd != NULL) relocatable = TRUE; else diff --git a/bfd/elf64-mips.c b/bfd/elf64-mips.c index 74ec7cbc4..b36743562 100644 --- a/bfd/elf64-mips.c +++ b/bfd/elf64-mips.c @@ -1543,14 +1543,14 @@ mips_elf64_literal_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, bfd_reloc_status_type ret; bfd_vma gp; - /* If we're relocating, and this is an external symbol, we don't - want to change anything. */ + /* R_MIPS_LITERAL relocations are defined for local symbols only. */ if (output_bfd != NULL && (symbol->flags & BSF_SECTION_SYM) == 0 && (symbol->flags & BSF_LOCAL) != 0) { - reloc_entry->address += input_section->output_offset; - return bfd_reloc_ok; + *error_message = (char *) + _("literal relocation occurs for an external symbol"); + return bfd_reloc_outofrange; } /* FIXME: The entries in the .lit8 and .lit4 sections should be merged. */ diff --git a/bfd/elfn32-mips.c b/bfd/elfn32-mips.c index d87c45c07..228601caa 100644 --- a/bfd/elfn32-mips.c +++ b/bfd/elfn32-mips.c @@ -1348,6 +1348,16 @@ mips_elf_literal_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, bfd_reloc_status_type ret; bfd_vma gp; + /* R_MIPS_LITERAL relocations are defined for local symbols only. */ + if (output_bfd != NULL + && (symbol->flags & BSF_SECTION_SYM) == 0 + && (symbol->flags & BSF_LOCAL) != 0) + { + *error_message = (char *) + _("literal relocation occurs for an external symbol"); + return bfd_reloc_outofrange; + } + /* FIXME: The entries in the .lit8 and .lit4 sections should be merged. */ if (output_bfd != NULL) relocatable = TRUE; -- 2.11.4.GIT