buglibffcall - foreign function call libraries - Bugs: bug #52510, mips (32-bit): please upgrade to...

 
 

bug #52510: mips (32-bit): please upgrade to O32 FPXX ABI

Submitter:  Sébastien Villemot <svillemot>
Submitted:  Sun 26 Nov 2017 05:18:51 PM UTC
   
 
Category:  None Severity:  3 - Normal
Item Group:  None Status:  Fix Released
Privacy:  Public Assigned to:  haible
Open/Closed:  Closed
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Thu 22 Aug 2019 01:49:12 AM UTC, comment #6: 

This is now fixed, through
https://git.savannah.gnu.org/gitweb/?p=libffcall.git;a=commitdiff;h=2bbad894b4b1b1ac4290e1fb451aeca05901f9a7

I kept your approach with '-fno-tree-dce', because the obvious idiom that works in avcall-mips64.c and avcall-mipsn32.c does not work in avcall-mips.c. Thanks!

Bruno Haible <haible>
Group administrator
Mon 19 Feb 2018 07:31:34 AM UTC, comment #5: 

Note that this issue is still present in ffcall 2.1, and that the Debian-specific patch for 32-bit mips is therefore still needed.

Sébastien Villemot <svillemot>
Sun 26 Nov 2017 06:59:58 PM UTC, comment #4: 

Wow! Kudos.

> an alternative fix is to do something with "space", like writing to it with "*space=0;"


I'll experiment with a source code change, like this. Thanks.

Bruno Haible <haible>
Group administrator
Sun 26 Nov 2017 06:53:24 PM UTC, comment #3: 

Basically here is how I figured it out: using gdb, it became clear that the crash was coming from a stack corruption. Then I look at the generated assembly for avcall-mips.c, and I realized that the instruction decreasing the stack pointer by 1032 bytes had disappeared.

Sébastien Villemot <svillemot>
Sun 26 Nov 2017 06:47:21 PM UTC, comment #2: 

Indeed I was getting a crash in avcall before adding -fno-tree-dce (an alternative fix is to do something with "space", like writing to it with "*space=0;").

Sébastien Villemot <svillemot>
Sun 26 Nov 2017 06:36:05 PM UTC, comment #1: 

Hi Sébastien,

This is great work! I had already attempted to overcome the "float register should be even" error that I got when using the cross toolchain on Ubuntu, but that required me to upgrade to a gcc-5.x, and that in turn caused avcall to crash.

Are you saying that libffcall passes "make check" with your patch, and thus '-fno-tree-dce' is the fix to the avcall crash?

Bruno Haible <haible>
Group administrator
Sun 26 Nov 2017 05:18:51 PM UTC, original submission:  

Hi,

Since GCC 5, the ABI for the Debian 32-bit mips ports has changed: it is now using the FPXX extension of the O32 ABI (see [1], [2] and [3] for some background).

As a consequence, the assembly files shipped for the O32 ABI (on both little- and big-endian) fail to compile, because they try to access odd-numbered floating point registers.

Here on a Debian unstable/sid system:

$ mipsel-linux-gnu-gcc -I. -I../common  -c avcall-mipsel-linux.s
avcall-mipsel-linux.s: Assembler messages:
avcall-mipsel-linux.s:320: Error: float register should be even, was 1


So basically what is needed (at least for Debian 32-bit mips ports) is to regenerate all the assembly files (using a version of gcc that defaults to the FPXX extension).

Also note that, for avcall, I had to add the -fno-tree-dce optimization flag, otherwise the call to __builtin_alloca() in avcall-mips.c is optimized out (because the variable "space" is not explicitly used).

For information, I attach the patch that I am going to apply to the Debian package. The resulting code compiles on both little- and big-endian 32-bit mips, and passes all the tests.

Best,

Sébastien

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=825342
[2] https://gcc.gnu.org/gcc-5/changes.html
[3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=789612

Sébastien Villemot <svillemot>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

Attached Files
file #42489:  mips-fpxx.patch added by svillemot (76KiB - text/x-patch)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by haible (Posted a comment)
  • -email is unavailable- added by svillemot (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 6 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-01-04 haible StatusFixed Fix Released
    2019-08-22 haible StatusConfirmed Fixed
        Open/ClosedOpen Closed
    2017-11-26 haible StatusNone Confirmed
        Assigned toNone haible
    2017-11-26 svillemot Attached File- Added mips-fpxx.patch, #42489

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code