diff options
author | Alan Modra <amodra@gmail.com> | 2019-08-14 16:31:05 +0930 |
---|---|---|
committer | Alan Modra <amodra@gmail.com> | 2019-08-16 13:37:54 +0930 |
commit | 63f6e94fb3cc5b6a2cfb8c28686f150e7226ab7e (patch) | |
tree | 61b7056baab6cde1bcf791bb73ed2d27c26d40d9 /bfd | |
parent | d8f9e51c361dfb53de3eca8d84f8938380af60ff (diff) | |
download | binutils-63f6e94fb3cc5b6a2cfb8c28686f150e7226ab7e.zip binutils-63f6e94fb3cc5b6a2cfb8c28686f150e7226ab7e.tar.gz binutils-63f6e94fb3cc5b6a2cfb8c28686f150e7226ab7e.tar.bz2 |
Aligned vs. unaligned ppc32 relocs
Given R_PPC_ADDR32 or R_PPC_UADDR32 relocs, this patch generates
R_PPC_ADDR32 or R_PPC_UADDR32 dynamic relocs from either type
depending on whether r_offset is 4-byte aligned, and similarly for
R_PPC_ADDR16/R_PPC_UADDR16.
* elf32-ppc.c (ppc_elf_relocate_section): Optimize unaligned relocs.
Diffstat (limited to 'bfd')
-rw-r--r-- | bfd/ChangeLog | 4 | ||||
-rw-r--r-- | bfd/elf32-ppc.c | 8 |
2 files changed, 12 insertions, 0 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 8e63c9b..5c3efb9 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,7 @@ +2019-08-16 Alan Modra <amodra@gmail.com> + + * elf32-ppc.c (ppc_elf_relocate_section): Optimize unaligned relocs. + 2019-08-15 Jim Wilson <jimw@sifive.com> * elfnn-riscv.c (perform_relocation) <R_RISCV_RVC_LUI>: If diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index e683590..78d39ef 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -8157,6 +8157,14 @@ ppc_elf_relocate_section (bfd *output_bfd, outrel.r_offset += (input_section->output_section->vma + input_section->output_offset); + /* Optimize unaligned reloc use. */ + if ((r_type == R_PPC_ADDR32 && (outrel.r_offset & 3) != 0) + || (r_type == R_PPC_UADDR32 && (outrel.r_offset & 3) == 0)) + r_type ^= R_PPC_ADDR32 ^ R_PPC_UADDR32; + if ((r_type == R_PPC_ADDR16 && (outrel.r_offset & 1) != 0) + || (r_type == R_PPC_UADDR16 && (outrel.r_offset & 1) == 0)) + r_type ^= R_PPC_ADDR16 ^ R_PPC_UADDR16; + if (skip) memset (&outrel, 0, sizeof outrel); else if (!SYMBOL_REFERENCES_LOCAL (info, h)) |