public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Fix ppc32 lrint (BZ #3155)
@ 2006-09-07 13:38 Jakub Jelinek
  2006-09-07 13:47 ` Ulrich Drepper
  2006-09-07 16:18 ` Steven Munroe
  0 siblings, 2 replies; 3+ messages in thread
From: Jakub Jelinek @ 2006-09-07 13:38 UTC (permalink / raw)
  To: Ulrich Drepper, Steven Munroe; +Cc: Glibc hackers

Hi!

PPC32 ABI forbids stack accesses below r1 (unlike PPC64 ABI).
The following patch fixes lrint which was violating this (detected by
valgrind).
There are 4 other ppc32 files that violate this:
libc/sysdeps/powerpc/powerpc32/fpu/fprrest.S
libc/sysdeps/powerpc/powerpc32/fpu/fprsave.S
libc/sysdeps/powerpc/powerpc32/gprrest0.S
libc/sysdeps/powerpc/powerpc32/gprsave0.S
The stubs from those files aren't exported from libc.so.6 nor actually
used for anything there, so I wonder if we can't nuke them altogether,
or if they should move to libc_nonshared.a after making all the functions
.hidden there.  GCC provides (some of) the PPC32 ABI mandates stubs
in crtsavres.o (and there it accesses memory below r11, not r1),
so I'm not 100% if we need these at all.

2006-09-07  Jakub Jelinek  <jakub@redhat.com>

	[BZ #3155]
	* sysdeps/powerpc/powerpc32/fpu/s_lrint.S (__lrint): Don't access
	stack below r1.

--- libc/sysdeps/powerpc/powerpc32/fpu/s_lrint.S.jj	2006-01-29 21:10:24.000000000 +0100
+++ libc/sysdeps/powerpc/powerpc32/fpu/s_lrint.S	2006-09-07 15:23:38.000000000 +0200
@@ -21,13 +21,15 @@
 #include <math_ldbl_opt.h>
 
 /* long int[r3] __lrint (double x[fp1])  */
-ENTRY (__lrint)	
+ENTRY (__lrint)
+	stwu	r1,-16(r1)
 	fctiw	fp13,fp1
-	stfd	fp13,-8(r1)
+	stfd	fp13,8(r1)
 	nop	/* Insure the following load is in a different dispatch group */
 	nop	/* to avoid pipe stall on POWER4&5.  */
 	nop
-	lwz	r3,-4(r1)	
+	lwz	r3,12(r1)
+	addi	r1,r1,16
 	blr
 	END (__lrint)
 

	Jakub

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

end of thread, other threads:[~2006-09-07 16:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-07 13:38 [PATCH] Fix ppc32 lrint (BZ #3155) Jakub Jelinek
2006-09-07 13:47 ` Ulrich Drepper
2006-09-07 16:18 ` Steven Munroe

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).