From dad27d18ac0175ce7d0a2859b9b0e638c3eb46a5 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 17 Jun 2003 12:37:26 +0000 Subject: [PATCH] * elf64-ppc.c (ppc64_elf_relocate_section): Optimize unaligned relocs. --- bfd/ChangeLog | 4 ++++ bfd/elf64-ppc.c | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index c6b6b1ee841..f738d5a1aa0 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,7 @@ +2003-06-17 Alan Modra + + * elf64-ppc.c (ppc64_elf_relocate_section): Optimize unaligned relocs. + 2003-06-17 Nick Clifton * elflink.h (elf_gc_record_vtentry): Allocate an extra element diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c index 371abb1b583..ca58c10fca9 100644 --- a/bfd/elf64-ppc.c +++ b/bfd/elf64-ppc.c @@ -8272,6 +8272,26 @@ ppc64_elf_relocate_section (output_bfd, info, input_bfd, input_section, } } + /* Optimize unaligned reloc use. */ + if ((ELF64_R_TYPE (outrel.r_info) == R_PPC64_ADDR64 + && (outrel.r_offset & 7) != 0) + || (ELF64_R_TYPE (outrel.r_info) == R_PPC64_UADDR64 + && (outrel.r_offset & 7) == 0)) + outrel.r_info ^= (ELF64_R_INFO (0, R_PPC64_ADDR64) + ^ ELF64_R_INFO (0, R_PPC64_UADDR64)); + else if ((ELF64_R_TYPE (outrel.r_info) == R_PPC64_ADDR32 + && (outrel.r_offset & 3) != 0) + || (ELF64_R_TYPE (outrel.r_info) == R_PPC64_UADDR32 + && (outrel.r_offset & 3) == 0)) + outrel.r_info ^= (ELF64_R_INFO (0, R_PPC64_ADDR32) + ^ ELF64_R_INFO (0, R_PPC64_UADDR32)); + else if ((ELF64_R_TYPE (outrel.r_info) == R_PPC64_ADDR16 + && (outrel.r_offset & 1) != 0) + || (ELF64_R_TYPE (outrel.r_info) == R_PPC64_UADDR16 + && (outrel.r_offset & 1) == 0)) + outrel.r_info ^= (ELF64_R_INFO (0, R_PPC64_ADDR16) + ^ ELF64_R_INFO (0, R_PPC64_UADDR16)); + sreloc = elf_section_data (input_section)->sreloc; if (sreloc == NULL) abort (); -- 2.30.2