This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH 1/1] Don't convert R_SPARC_32 to R_SPARC_RELATIVE if class is ELFCLASS64
- From: James Clarke <jrtc27 at jrtc27 dot com>
- To: binutils at sourceware dot org
- Cc: James Clarke <jrtc27 at jrtc27 dot com>
- Date: Wed, 11 May 2016 11:10:36 +0100
- Subject: [PATCH 1/1] Don't convert R_SPARC_32 to R_SPARC_RELATIVE if class is ELFCLASS64
- Authentication-results: sourceware.org; auth=none
- References: <1462961436-40750-1-git-send-email-jrtc27 at jrtc27 dot com>
bfd/
* elfxx-sparc.c (_bfd_sparc_elf_relocate_section): Don't convert
R_SPARC_32 to R_SPARC_RELATIVE if class is ELFCLASS64.
gold/
* sparc.cc (Target_sparc::Scan::local): Don't convert R_SPARC_32 to
R_SPARC_RELATIVE if class is ELFCLASS64.
(Target_sparc::Scan::global): Likewise.
---
bfd/elfxx-sparc.c | 3 ++-
gold/sparc.cc | 12 +++++++-----
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c
index fc12805..db2d127 100644
--- a/bfd/elfxx-sparc.c
+++ b/bfd/elfxx-sparc.c
@@ -3481,7 +3481,8 @@ _bfd_sparc_elf_relocate_section (bfd *output_bfd,
}
else
{
- if (r_type == R_SPARC_32 || r_type == R_SPARC_64)
+ if ((!ABI_64_P (output_bfd) && r_type == R_SPARC_32)
+ || (ABI_64_P (output_bfd) && r_type == R_SPARC_64))
{
outrel.r_info = SPARC_ELF_R_INFO (htab, NULL,
0, R_SPARC_RELATIVE);
diff --git a/gold/sparc.cc b/gold/sparc.cc
index 10a5031..e5e0146 100644
--- a/gold/sparc.cc
+++ b/gold/sparc.cc
@@ -2292,7 +2292,9 @@ Target_sparc<size, big_endian>::Scan::local(
// apply the link-time value, so we flag the location with
// an R_SPARC_RELATIVE relocation so the dynamic loader can
// relocate it easily.
- if (parameters->options().output_is_position_independent())
+ if (parameters->options().output_is_position_independent()
+ && ((size == 64 && r_type == elfcpp::R_SPARC_64)
+ || (size == 32 && r_type == elfcpp::R_SPARC_32)))
{
Reloc_section* rela_dyn = target->rela_dyn_section(layout);
unsigned int r_sym = elfcpp::elf_r_sym<size>(reloc.get_r_info());
@@ -2300,9 +2302,9 @@ Target_sparc<size, big_endian>::Scan::local(
output_section, data_shndx,
reloc.get_r_offset(),
reloc.get_r_addend(), is_ifunc);
+ break;
}
- break;
-
+ /* Fall through */
case elfcpp::R_SPARC_HIX22:
case elfcpp::R_SPARC_LOX10:
case elfcpp::R_SPARC_H34:
@@ -2766,8 +2768,8 @@ Target_sparc<size, big_endian>::Scan::global(
reloc.get_r_offset(),
reloc.get_r_addend());
}
- else if ((r_type == elfcpp::R_SPARC_32
- || r_type == elfcpp::R_SPARC_64)
+ else if (((size == 64 && r_type == elfcpp::R_SPARC_64)
+ || (size == 32 && r_type == elfcpp::R_SPARC_32))
&& gsym->can_use_relative_reloc(false))
{
Reloc_section* rela_dyn = target->rela_dyn_section(layout);
--
2.8.2