public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Power7 thread-safe plt call stubs
@ 2012-12-05  4:59 Alan Modra
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2012-12-05  4:59 UTC (permalink / raw)
  To: binutils

Fixes an off by one error in thread-safe power7 plt call stubs,
affecting large executables and shared libraries that call more than
32767 functions.  The retry path runs off into the weeds for stubs
32768 and above.  Committed.

	* elf64-ppc.c (build_plt_stub): Fix off by one error in branch
	to glink.

Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.396
diff -u -p -r1.396 elf64-ppc.c
--- bfd/elf64-ppc.c	6 Nov 2012 05:18:03 -0000	1.396
+++ bfd/elf64-ppc.c	5 Dec 2012 02:41:27 -0000
@@ -9653,8 +9653,8 @@ build_plt_stub (struct ppc_link_hash_tab
       bfd_vma glinkoff = GLINK_CALL_STUB_SIZE + pltindex * 8;
       bfd_vma to, from;
 
-      if (pltindex > 32767)
-	glinkoff += (pltindex - 32767) * 4;
+      if (pltindex > 32768)
+	glinkoff += (pltindex - 32768) * 4;
       to = (glinkoff
 	    + htab->glink->output_offset
 	    + htab->glink->output_section->vma);

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Power7 thread-safe plt call stubs
@ 2013-01-30 22:30 Alan Modra
  0 siblings, 0 replies; 2+ messages in thread
From: Alan Modra @ 2013-01-30 22:30 UTC (permalink / raw)
  To: binutils; +Cc: matz

We normally have call stubs before glink code so I hadn't seen this
obvious bug, but apparently this can occur in a glibc build.  Adding a
negative offset carries over from the insn branch offset field to the
opcode..

	* elf64-ppc.c (build_plt_stub): Correct plt stub branch to glink.

Index: bfd/elf64-ppc.c
===================================================================
RCS file: /cvs/src/src/bfd/elf64-ppc.c,v
retrieving revision 1.400
diff -u -p -r1.400 elf64-ppc.c
--- bfd/elf64-ppc.c	28 Jan 2013 12:30:17 -0000	1.400
+++ bfd/elf64-ppc.c	30 Jan 2013 22:23:06 -0000
@@ -9772,7 +9772,7 @@ build_plt_stub (struct ppc_link_hash_tab
     {
       bfd_put_32 (obfd, CMPLDI_R2_0, p),			p += 4;
       bfd_put_32 (obfd, BNECTR_P4, p),				p += 4;
-      bfd_put_32 (obfd, B_DOT + cmp_branch_off, p),		p += 4;
+      bfd_put_32 (obfd, B_DOT | (cmp_branch_off & 0x3fffffc), p), p += 4;
     }
   else
     bfd_put_32 (obfd, BCTR, p),					p += 4;

-- 
Alan Modra
Australia Development Lab, IBM

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-01-30 22:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-05  4:59 Power7 thread-safe plt call stubs Alan Modra
2013-01-30 22:30 Alan Modra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).