From 765f2ef6956841baed46e6203a7b9be1b248285c Mon Sep 17 00:00:00 2001 From: "Maciej W. Rozycki" Date: Mon, 7 Feb 2005 02:44:59 +0000 Subject: [PATCH] * elf32-mips.c (mips_elf_gprel32_reloc): Reject R_MIPS_GPREL32 relocations against external symbols. * elf64-mips.c (mips_elf64_gprel32_reloc): Replace an incorrect comment. --- bfd/ChangeLog | 7 +++++++ bfd/elf32-mips.c | 10 ++++++++++ bfd/elf64-mips.c | 3 +-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index b13e41c3e7..033bf574de 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,10 @@ +2005-02-07 Maciej W. Rozycki + + * elf32-mips.c (mips_elf_gprel32_reloc): Reject + R_MIPS_GPREL32 relocations against external symbols. + * elf64-mips.c (mips_elf64_gprel32_reloc): Replace an incorrect + comment. + 2005-02-07 Alan Modra * elf-bfd.h (elf_string_from_elf_strtab): Delete macro. diff --git a/bfd/elf32-mips.c b/bfd/elf32-mips.c index 9774215d01..07d8ba4b5e 100644 --- a/bfd/elf32-mips.c +++ b/bfd/elf32-mips.c @@ -800,6 +800,16 @@ mips_elf_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, bfd_reloc_status_type ret; bfd_vma gp; + /* R_MIPS_GPREL32 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 *) + _("32bits gp relative 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 699b8628cf..e1051be9b0 100644 --- a/bfd/elf64-mips.c +++ b/bfd/elf64-mips.c @@ -1586,8 +1586,7 @@ mips_elf64_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol, bfd_vma relocation; bfd_vma val; - /* If we're relocating, and this is an external symbol, we don't want - to change anything. */ + /* R_MIPS_GPREL32 relocations are defined for local symbols only. */ if (output_bfd != NULL && (symbol->flags & BSF_SECTION_SYM) == 0 && (symbol->flags & BSF_LOCAL) != 0) -- 2.34.1