Bug 7001 - setjmp/longjmp do not save/restore correct FPU registers in N32 ABI mode
Summary: setjmp/longjmp do not save/restore correct FPU registers in N32 ABI mode
Status: RESOLVED INVALID
Alias: None
Product: glibc
Classification: Unclassified
Component: ports (show other bugs)
Version: 2.8
: P2 normal
Target Milestone: ---
Assignee: Roland McGrath
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-11-01 10:10 UTC by Nicolas S. Dade
Modified: 2014-07-01 21:21 UTC (History)
1 user (show)

See Also:
Host: mips64-unknown-linux-gnu
Target:
Build: i686-unknown-linux-gnu
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nicolas S. Dade 2008-11-01 10:10:09 UTC
In the files

  glibc/ports/sysdeps/mips/mips64/setjmp_aux.c
  glibc/ports/sysdeps/mips/mips64/__longjmp.c

the innermost #if checks look like this:

  #if _MIPS_SIM == _ABI64
     [ save/restore f24, f25, ... f31 ]
  #else
     [ save/restore f20,, f22, ... f30 ] (Even registers only b/c on 32-bit CPUs
the registers are paired even/odd to hold double precision FP numbers)
  #endif

Thus in _ABIN32 (64-bit CPU using 32-bit pointers) the 32-bit CPU code is
selected, which fails to save or restore any odd numbered registers. The N32 ABI
defines f24-f31 as callee-saved, same as _ABI64 does.

One fix would be to change the tests from

-  #if _MIPS_SIM == _ABI64
+  #if _MIPS_SIM != _ABIO32

This is present in at least glibc-ports-2.7 (where we discovered it), 2.8 and in
CVS HEAD.


-Nicolas Dade
Comment 1 Joseph Myers 2010-03-23 14:47:41 UTC
My copy of the MIPSpro(TM) N32 ABI Handbook says "There are eight callee-saved
floating point registers, $f24..$f31 for the 64-bit interface. There are six for
the n32 ABI, the six even registers in $f20..$f30.".  This agrees with glibc and
GCC.