[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 4/4] pkl: Mark insns contains DIV/MOD ops as non-relocatable
From: |
Mohammad-Reza Nabipoor |
Subject: |
[PATCH 4/4] pkl: Mark insns contains DIV/MOD ops as non-relocatable |
Date: |
Thu, 27 Jan 2022 04:10:10 +0330 |
2022-01-27 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* libpoke/pvm.jitter (iogetb): Mark as `non-relocatable` because
of / and %.
(formati): Likewise.
(formatiu): Likewise.
(formatl): Likewise.
(formatlu): Likewise.
(divi): Likewise.
(diviu): Likewise.
(divl): Likewise.
(divlu): Likewise.
(modi): Likewise.
(modiu): Likewise.
(modl): Likewise.
(modlu): Likewise.
* etc/pvm-wraps-static-whitelist: Update.
---
ChangeLog | 18 ++++++++++++++++++
etc/pvm-wraps-whitelist | 12 ++++++++++++
libpoke/pvm.jitter | 13 +++++++++++++
3 files changed, 43 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 4ea3c669..79853953 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,21 @@
+2022-01-27 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
+
+ * libpoke/pvm.jitter (iogetb): Mark as `non-relocatable` because
+ of / and %.
+ (formati): Likewise.
+ (formatiu): Likewise.
+ (formatl): Likewise.
+ (formatlu): Likewise.
+ (divi): Likewise.
+ (diviu): Likewise.
+ (divl): Likewise.
+ (divlu): Likewise.
+ (modi): Likewise.
+ (modiu): Likewise.
+ (modl): Likewise.
+ (modlu): Likewise.
+ * etc/pvm-wraps-static-whitelist: Update.
+
2022-01-27 Mohammad-Reza Nabipoor <mnabipoor@gnu.org>
* libpoke/pvm.jitter (wrapped-functions): Add missing functions.
diff --git a/etc/pvm-wraps-whitelist b/etc/pvm-wraps-whitelist
index 90e26b2e..267b23d6 100644
--- a/etc/pvm-wraps-whitelist
+++ b/etc/pvm-wraps-whitelist
@@ -26,3 +26,15 @@ strcpy
strlen
strncat
strncpy
+# These are funcalls generated by GCC for / and % in some architectures.
+# We only use / and % from within instructions marked as non-relocatable.
+__divdi3
+__moddi3
+__udivdi3
+__umoddi3
+__aeabi_idiv
+__aeabi_idivmod
+__aeabi_ldivmod
+__aeabi_uidiv
+__aeabi_uidivmod
+__aeabi_uldivmod
diff --git a/libpoke/pvm.jitter b/libpoke/pvm.jitter
index 0b0ec71e..0cb1cf7d 100644
--- a/libpoke/pvm.jitter
+++ b/libpoke/pvm.jitter
@@ -1776,6 +1776,7 @@ end
# Exceptions: PVM_E_NO_IOS
instruction iogetb ()
+ non-relocatable
branching # because of PVM_RAISE_DIRECT
# XXX make non-relocatable: see raise
code
@@ -2229,6 +2230,7 @@ end
# Stack: ( INT INT -- STR )
instruction formati (?n)
+ non-relocatable
code
int base = PVM_VAL_INT (JITTER_TOP_STACK ());
char res[32 + 2 /* suffix */ + 1 /* nul */];
@@ -2245,6 +2247,7 @@ end
# Stack: ( UINT INT -- STR )
instruction formatiu (?n)
+ non-relocatable
code
int base = PVM_VAL_INT (JITTER_TOP_STACK ());
char res[32 + 2 /* suffix */ + 1 /* nul */];
@@ -2261,6 +2264,7 @@ end
# Stack: ( LONG INT -- STR )
instruction formatl (?n)
+ non-relocatable
code
int base = PVM_VAL_INT (JITTER_TOP_STACK ());
char res[64 + 2 /* suffix */ + 1 /* nul */];
@@ -2277,6 +2281,7 @@ end
# Stack: ( ULONG INT -- STR )
instruction formatlu (?n)
+ non-relocatable
code
int base = PVM_VAL_INT (JITTER_TOP_STACK ());
char res[64 + 2 /* suffix */ + 1 /* nul */];
@@ -2845,6 +2850,7 @@ end
# Exceptions: PVM_E_DIV_BY_ZERO
instruction divi ()
+ non-relocatable
branching # because of PVM_RAISE_DIRECT
code
PVM_DIV_SIGNED (INT, int);
@@ -2861,6 +2867,7 @@ end
# Exceptions: PVM_E_DIV_BY_ZERO
instruction diviu ()
+ non-relocatable
branching # because of PVM_RAISE_DIRECT
code
PVM_CHECKED_BINOP (UINT, UINT, UINT, /);
@@ -2876,6 +2883,7 @@ end
# Exceptions: PVM_E_DIV_BY_ZERO
instruction divl ()
+ non-relocatable
branching # because of PVM_RAISE_DIRECT
code
PVM_DIV_SIGNED (LONG, int64_t);
@@ -2892,6 +2900,7 @@ end
# Exceptions: PVM_E_DIV_BY_ZERO
instruction divlu ()
+ non-relocatable
branching # because of PVM_RAISE_DIRECT
code
PVM_CHECKED_BINOP (ULONG, ULONG, ULONG, /);
@@ -2907,6 +2916,7 @@ end
# Exceptions: PVM_E_DIV_BY_ZERO
instruction modi ()
+ non-relocatable
branching # because of PVM_RAISE_DIRECT
code
PVM_MOD_SIGNED (INT, int);
@@ -2923,6 +2933,7 @@ end
# Exceptions: PVM_E_DIV_BY_ZERO
instruction modiu ()
+ non-relocatable
branching # because of PVM_RAISE_DIRECT
code
PVM_CHECKED_BINOP (UINT, UINT, UINT, %);
@@ -2938,6 +2949,7 @@ end
# Exceptions: PVM_E_DIV_BY_ZERO
instruction modl ()
+ non-relocatable
branching # because of PVM_RAISE_DIRECT
code
PVM_MOD_SIGNED (LONG, int64_t);
@@ -2953,6 +2965,7 @@ end
# Exceptions: PVM_E_DIV_BY_ZERO
instruction modlu ()
+ non-relocatable
branching # because of PVM_RAISE_DIRECT
code
PVM_CHECKED_BINOP (ULONG, ULONG, ULONG, %);
--
2.34.1