* elf64-ppc.c (ppc64_elf_relocate_section): Optimize unaligned relocs.
authorAlan Modra <amodra@gmail.com>
Tue, 17 Jun 2003 12:37:26 +0000 (12:37 +0000)
committerAlan Modra <amodra@gmail.com>
Tue, 17 Jun 2003 12:37:26 +0000 (12:37 +0000)
bfd/ChangeLog
bfd/elf64-ppc.c

index c6b6b1ee84122c26356fed30d352edc4cef31235..f738d5a1aa09b7432376cc5e2095c1548851d34b 100644 (file)
@@ -1,3 +1,7 @@
+2003-06-17  Alan Modra  <amodra@bigpond.net.au>
+
+       * elf64-ppc.c (ppc64_elf_relocate_section): Optimize unaligned relocs.
+
 2003-06-17  Nick Clifton  <nickc@redhat.com>
 
        * elflink.h (elf_gc_record_vtentry): Allocate an extra element
index 371abb1b583726f30640badc4b36029a9be2b8de..ca58c10fca90728fd2f7f79c76a3617234773d63 100644 (file)
@@ -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 ();