]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libffi: Fix MIPS r6 support
authorYunQiang Su <yunqiang.su@cipunited.com>
Sat, 28 Aug 2021 12:17:18 +0000 (08:17 -0400)
committerYunQiang Su <syq@debian.org>
Mon, 30 Aug 2021 08:03:59 +0000 (16:03 +0800)
for some instructions, MIPS r6 uses different encoding other than
the previous releases.

1. mips/n32.S disable .set mips4: since it casuses old insn encoding
   is used.
   https://github.com/libffi/libffi/pull/396 has been accepted as:
     94c102aa69b04337f63498e0e6551fcdce549ae5
2. mips/ffi.c: the encoding for JR is hardcoded: we need to use
   different value for r6 and pre-r6.
   https://github.com/libffi/libffi/pull/401 has been accpeted as:
     746dbe3a6a79a41931c03b51df2972be4d5e5028

libffi/
PR libffi/83636
* src/mips/n32.S: disable .set mips4
* src/mips/ffi.c: use different JR encoding for r6.

libffi/src/mips/ffi.c
libffi/src/mips/n32.S

index 5d0dd70cb32884a838d1855f8232a8f64d13113a..ecd783a56c553bd9d2a49c58b2d463969a4bf481 100644 (file)
@@ -698,7 +698,11 @@ ffi_prep_closure_loc (ffi_closure *closure,
   /* lui  $12,high(codeloc) */
   tramp[2] = 0x3c0c0000 | ((unsigned)codeloc >> 16);
   /* jr   $25          */
+#if !defined(__mips_isa_rev) || (__mips_isa_rev<6)
   tramp[3] = 0x03200008;
+#else
+  tramp[3] = 0x03200009;
+#endif
   /* ori  $12,low(codeloc)  */
   tramp[4] = 0x358c0000 | ((unsigned)codeloc & 0xffff);
 #else
@@ -726,7 +730,11 @@ ffi_prep_closure_loc (ffi_closure *closure,
   /* ori  $25,low(fn)  */
   tramp[10] = 0x37390000 | ((unsigned long)fn  & 0xffff);
   /* jr   $25          */
+#if !defined(__mips_isa_rev) || (__mips_isa_rev<6)
   tramp[11] = 0x03200008;
+#else
+  tramp[11] = 0x03200009;
+#endif
   /* ori  $12,low(codeloc)  */
   tramp[12] = 0x358c0000 | ((unsigned long)codeloc & 0xffff);
 
index c6985d30a6f6402edf83d0d548d2a3b9261106d9..06e6c46076bf7c3cd697b51e6e00163c8cd7ba65 100644 (file)
@@ -43,7 +43,9 @@
 #ifdef __GNUC__
        .abicalls
 #endif
+#if !defined(__mips_isa_rev) || (__mips_isa_rev<6)
        .set mips4
+#endif
        .text
        .align  2
        .globl  ffi_call_N32