[PATCH] Fix ppc32 lrint (BZ #3155)

Jakub Jelinek jakub@redhat.com
Thu Sep 7 13:38:00 GMT 2006


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



More information about the Libc-hacker mailing list