This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Use -frounding-math for math testsuite
From: Andreas Jaeger <aj@suse.com>
Date: Mon, 07 May 2012 22:14:59 +0200
>> * Continue to help Dave fix the bug.
>
> ;)
I think I found the bug, it seems one of the Sparc PIC register setup
macros needs an adjustment.
The bug triggers because the address of one of the IFUNC resolvers
straddles a 0x400 boundary. The peculiar nature of what's necessary
to trigger this problem explains 1) why I've never seen it before and
2) why something benign like -frounding-math could cause it.
The problem is how I coded the PIC register setup. The canonical
method to setup the PIC register is:
sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %PIC_REG
call STUB
or %PIC_REG, %lo(_GLOBAL_OFFSET_TABLE_+4), %PIC_REG
and STUB is:
STUB:
retl
add %PIC_REG, %o7, %PIC_REG
It is critical that the _GLOBAL_OFFSET_TABLE references have those
"-4" and "+4" offsets, because they represent the offset at which
those instructions sit relative to the 'call'.
However, in the leaf version of the PIC register setup macro (which
the IFUNC resolvers use) I move the initial "sethi" up one
instruction.
Most of the time this never matters. But at an exact 0x400
instruction address boundary it does.
I'm putting the following patch through my tests:
2012-05-07 David S. Miller <davem@davemloft.net>
* sysdeps/sparc/sysdep.h (SETUP_PIC_REG_LEAF): The 'sethi' needs to
be exactly right before the 'call'.
diff --git a/sysdeps/sparc/sysdep.h b/sysdeps/sparc/sysdep.h
index 2702620..36d1ff4 100644
--- a/sysdeps/sparc/sysdep.h
+++ b/sysdeps/sparc/sysdep.h
@@ -69,8 +69,8 @@ __sparc_get_pc_thunk.reg: \
#define SETUP_PIC_REG_LEAF(reg, tmp) \
SPARC_PIC_THUNK(reg) \
- sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %##reg; \
mov %o7, %##tmp; \
+ sethi %hi(_GLOBAL_OFFSET_TABLE_-4), %##reg; \
call __sparc_get_pc_thunk.reg; \
or %##reg, %lo(_GLOBAL_OFFSET_TABLE_+4), %##reg; \
mov %##tmp, %o7;