From 1d5c94cb3e2e312fc37e7841d17ea98a02f0412c Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 16 Jun 2015 16:47:51 +0930 Subject: ppc476 linker workaround shared lib fixes again Huh, I can't even write a binary search properly. bfd/ * elf32-ppc.c (ppc_elf_relocate_section): Correct binary search of dynamic relocs. ld/testsuite/ * ld-powerpc/ppc476-shared.s: Repeat dynamic reloc generating insns. * ld-powerpc/ppc476-shared.d: Update. * ld-powerpc/ppc476-shared2.d: Update. --- bfd/elf32-ppc.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'bfd/elf32-ppc.c') diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index a947e8e..f1fbc66 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -9642,32 +9642,33 @@ ppc_elf_relocate_section (bfd *output_bfd, sreloc = elf_section_data (input_section)->sreloc; if (sreloc != NULL) { - bfd_byte *slo, *shi, *srelend; + Elf32_External_Rela *slo, *shi, *srelend; bfd_vma soffset; - slo = sreloc->contents; - shi = srelend - = slo + sreloc->reloc_count * sizeof (Elf32_External_Rela); + slo = (Elf32_External_Rela *) sreloc->contents; + shi = srelend = slo + sreloc->reloc_count; soffset = (offset + input_section->output_section->vma + input_section->output_offset); while (slo < shi) { - bfd_byte *srel = slo + (shi - slo) / 2; - bfd_elf32_swap_reloca_in (output_bfd, srel, &outrel); + Elf32_External_Rela *srel = slo + (shi - slo) / 2; + bfd_elf32_swap_reloca_in (output_bfd, (bfd_byte *) srel, + &outrel); if (outrel.r_offset < soffset) slo = srel + 1; else if (outrel.r_offset > soffset + 3) shi = srel; else { - bfd_byte *nextr = srel + sizeof (Elf32_External_Rela); - if (nextr != srelend) + if (srel + 1 != srelend) { - memmove (srel, nextr, srelend - nextr); - srel = srelend - sizeof (Elf32_External_Rela); + memmove (srel, srel + 1, + (srelend - (srel + 1)) * sizeof (*srel)); + srel = srelend - 1; } outrel.r_offset += patch_off - offset; - bfd_elf32_swap_reloca_out (output_bfd, &outrel, srel); + bfd_elf32_swap_reloca_out (output_bfd, &outrel, + (bfd_byte *) srel); break; } } -- cgit v1.1