summaryrefslogtreecommitdiff
path: root/gnu
diff options
context:
space:
mode:
authorthorpej <thorpej@NetBSD.org>2001-12-13 00:21:57 +0000
committerthorpej <thorpej@NetBSD.org>2001-12-13 00:21:57 +0000
commit7a3fcb2adfc3d88fcf0495fb40f87ca2d3c2adb9 (patch)
treeb74edfb9efa0bdb982e31cc0272611ed489ccd14 /gnu
parentd043d0d483fe2a47f3c3c9092171a4b8c13764c5 (diff)
Convert unaligned relocs to aligned relocs if they happen to be
aligned. Corresponds to part of rev 1.21 of this file in the master FSF sources. Thanks to Michael Rauch <mrauch@netbsd.org> for fishing out the patch.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/dist/toolchain/bfd/elf32-sparc.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/gnu/dist/toolchain/bfd/elf32-sparc.c b/gnu/dist/toolchain/bfd/elf32-sparc.c
index 091cd3917f7..4b9a767d822 100644
--- a/gnu/dist/toolchain/bfd/elf32-sparc.c
+++ b/gnu/dist/toolchain/bfd/elf32-sparc.c
@@ -1463,6 +1463,28 @@ elf32_sparc_relocate_section (output_bfd, info, input_bfd, input_section,
outrel.r_offset += (input_section->output_section->vma
+ input_section->output_offset);
+ /* Optimize unaligned reloc usage now that we know where
+ it finally resides. */
+ switch (r_type)
+ {
+ case R_SPARC_16:
+ if (outrel.r_offset & 1)
+ r_type = R_SPARC_UA16;
+ break;
+ case R_SPARC_UA16:
+ if (!(outrel.r_offset & 1))
+ r_type = R_SPARC_16;
+ break;
+ case R_SPARC_32:
+ if (outrel.r_offset & 3)
+ r_type = R_SPARC_UA32;
+ break;
+ case R_SPARC_UA32:
+ if (!(outrel.r_offset & 3))
+ r_type = R_SPARC_32;
+ break;
+ }
+
if (skip)
memset (&outrel, 0, sizeof outrel);
/* h->dynindx may be -1 if the symbol was marked to