This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb/binutils-2_25-branch] ppc476 linker workaround shared lib fixes again
- From: Alan Modra <amodra at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 10 Jul 2015 10:42:51 -0000
- Subject: [binutils-gdb/binutils-2_25-branch] ppc476 linker workaround shared lib fixes again
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=abe10d1d553bda2c9401a678b9651520df615850
commit abe10d1d553bda2c9401a678b9651520df615850
Author: Alan Modra <amodra@gmail.com>
Date: Tue Jun 16 16:47:51 2015 +0930
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.
Diff:
---
bfd/ChangeLog | 4 +++
bfd/elf32-ppc.c | 23 +++++++-------
ld/testsuite/ChangeLog | 5 +++
ld/testsuite/ld-powerpc/ppc476-shared.d | 54 +++++++++++++++++++++-----------
ld/testsuite/ld-powerpc/ppc476-shared.s | 8 ++++-
ld/testsuite/ld-powerpc/ppc476-shared2.d | 8 +++--
6 files changed, 70 insertions(+), 32 deletions(-)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index ab2bb50..81a22f1 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,6 +1,10 @@
2015-07-10 Alan Modra <amodra@gmail.com>
Apply from master
+ 2015-06-16 Alan Modra <amodra@gmail.com>
+ * elf32-ppc.c (ppc_elf_relocate_section): Correct binary search of
+ dynamic relocs.
+
2015-06-05 Alan Modra <amodra@gmail.com>
* elf64-ppc.c (ppc_elf_relocate_section): Move dynamic text
relocs with insns moved by --ppc476-workaround. Correct
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index ed19972..2f8ad71 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -9462,32 +9462,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;
}
}
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 7e9895d..3577d16 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,6 +1,11 @@
2015-07-10 Alan Modra <amodra@gmail.com>
Apply from master
+ 2015-06-16 Alan Modra <amodra@gmail.com>
+ * ld-powerpc/ppc476-shared.s: Repeat dynamic reloc generating insns.
+ * ld-powerpc/ppc476-shared.d: Update.
+ * ld-powerpc/ppc476-shared2.d: Update.
+
2015-06-05 Alan Modra <amodra@gmail.com>
* ld-powerpc/ppc476-shared.s,
* ld-powerpc/ppc476-shared.lnk,
diff --git a/ld/testsuite/ld-powerpc/ppc476-shared.d b/ld/testsuite/ld-powerpc/ppc476-shared.d
index 8fda847..fe438f4 100644
--- a/ld/testsuite/ld-powerpc/ppc476-shared.d
+++ b/ld/testsuite/ld-powerpc/ppc476-shared.d
@@ -8,23 +8,41 @@
Disassembly of section \.text:
-0+fffc <\.text>:
- fffc: (48 01 00 04|04 00 01 48) b 20000 .*
+0000fffc <\.text>:
+ fffc: (48 03 00 04|04 00 03 48) b 40000 .*
10000: (38 63 00 00|00 00 63 38) addi r3,r3,0
- 1000[02]: R_PPC_ADDR16_LO .bss
+ 1000[02]: R_PPC_ADDR16_LO \.bss
\.\.\.
- 1fff0: (42 9f 00 05|05 00 9f 42) bcl .*
- 1fff4: (7d 28 02 a6|a6 02 28 7d) mflr r9
- 1fff8: (3d 29 00 00|00 00 29 3d) addis r9,r9,0
- 1fff[8a]: R_PPC_REL16_HA .bss\+0x[46]
- 1fffc: (48 00 00 14|14 00 00 48) b 20010 .*
- 20000: (3c 60 00 00|00 00 60 3c) lis r3,0
- 2000[02]: R_PPC_ADDR16_HA .bss
- 20004: (4b fe ff fc|fc ff fe 4b) b 10000 .*
- 20008: (48 00 00 02|02 00 00 48) ba 0 .*
- 2000c: (48 00 00 02|02 00 00 48) ba 0 .*
- 20010: (39 29 01 00|00 01 29 39) addi r9,r9,256
- 2001[02]: R_PPC_REL16_LO .bss\+0x1[ce]
- 20014: (4b ff ff ec|ec ff ff 4b) b 20000 .*
- 20018: (48 00 00 02|02 00 00 48) ba 0 .*
- 2001c: (48 00 00 02|02 00 00 48) ba 0 .*
+ 1fffc: (48 02 00 14|14 00 02 48) b 40010 .*
+ 20000: (38 63 00 00|00 00 63 38) addi r3,r3,0
+ 2000[02]: R_PPC_ADDR16_LO \.bss
+ \.\.\.
+ 2fffc: (48 01 00 24|24 00 01 48) b 40020 .*
+ 30000: (38 63 00 00|00 00 63 38) addi r3,r3,0
+ 3000[02]: R_PPC_ADDR16_LO \.bss
+ \.\.\.
+ 3fff0: (42 9f 00 05|05 00 9f 42) bcl .*
+ 3fff4: (7d 28 02 a6|a6 02 28 7d) mflr r9
+ 3fff8: (3d 29 00 00|00 00 29 3d) addis r9,r9,0
+ 3fff[8a]: R_PPC_REL16_HA \.bss\+0x[46]
+ 3fffc: (48 00 00 34|34 00 00 48) b 40030 .*
+ 40000: (3c 60 00 00|00 00 60 3c) lis r3,0
+ 4000[02]: R_PPC_ADDR16_HA \.bss
+ 40004: (4b fc ff fc|fc ff fc 4b) b 10000 .*
+ 40008: (48 00 00 02|02 00 00 48) ba 0 .*
+ 4000c: (48 00 00 02|02 00 00 48) ba 0 .*
+ 40010: (3c 60 00 00|00 00 60 3c) lis r3,0
+ 4001[02]: R_PPC_ADDR16_HA \.bss
+ 40014: (4b fd ff ec|ec ff fd 4b) b 20000 .*
+ 40018: (48 00 00 02|02 00 00 48) ba 0 .*
+ 4001c: (48 00 00 02|02 00 00 48) ba 0 .*
+ 40020: (3c 60 00 00|00 00 60 3c) lis r3,0
+ 4002[02]: R_PPC_ADDR16_HA \.bss
+ 40024: (4b fe ff dc|dc ff fe 4b) b 30000 .*
+ 40028: (48 00 00 02|02 00 00 48) ba 0 .*
+ 4002c: (48 00 00 02|02 00 00 48) ba 0 .*
+ 40030: (39 29 01 50|50 01 29 39) addi r9,r9,336
+ 4003[02]: R_PPC_REL16_LO \.bss\+0x3[ce]
+ 40034: (4b ff ff cc|cc ff ff 4b) b 40000 .*
+ 40038: (48 00 00 02|02 00 00 48) ba 0 .*
+ 4003c: (48 00 00 02|02 00 00 48) ba 0 .*
diff --git a/ld/testsuite/ld-powerpc/ppc476-shared.s b/ld/testsuite/ld-powerpc/ppc476-shared.s
index 6774bad..e23b78a 100644
--- a/ld/testsuite/ld-powerpc/ppc476-shared.s
+++ b/ld/testsuite/ld-powerpc/ppc476-shared.s
@@ -1,8 +1,14 @@
.text
lis 3,x@ha
addi 3,3,x@l
+ .org 0x10000
+ lis 3,x@ha
+ addi 3,3,x@l
+ .org 0x20000
+ lis 3,x@ha
+ addi 3,3,x@l
- .org 0xfff4
+ .org 0x2fff4
bcl 20,31,.+4
0:
mflr 9
diff --git a/ld/testsuite/ld-powerpc/ppc476-shared2.d b/ld/testsuite/ld-powerpc/ppc476-shared2.d
index ebb8bf1..813ea2e 100644
--- a/ld/testsuite/ld-powerpc/ppc476-shared2.d
+++ b/ld/testsuite/ld-powerpc/ppc476-shared2.d
@@ -8,5 +8,9 @@
DYNAMIC RELOCATION RECORDS
OFFSET TYPE VALUE
-0001000[02] R_PPC_ADDR16_LO \.text\+0x000200f4
-0002000[02] R_PPC_ADDR16_HA \.text\+0x000200f4
+0001000[02] R_PPC_ADDR16_LO \.text\+0x00040144
+0002000[02] R_PPC_ADDR16_LO \.text\+0x00040144
+0003000[02] R_PPC_ADDR16_LO \.text\+0x00040144
+0004000[02] R_PPC_ADDR16_HA \.text\+0x00040144
+0004001[02] R_PPC_ADDR16_HA \.text\+0x00040144
+0004002[02] R_PPC_ADDR16_HA \.text\+0x00040144