From 22039c76bcac20c52d17cdddad86c1184e2f7395 Mon Sep 17 00:00:00 2001
From: Andre Maroneze <andre.oliveiramaroneze@cea.fr>
Date: Tue, 5 Mar 2019 15:35:01 +0100
Subject: [PATCH] [Libc] fix and improve stubs for strerror/strsignal

---
 share/libc/string.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/share/libc/string.c b/share/libc/string.c
index 99e54e162ad..fc5a7893720 100644
--- a/share/libc/string.c
+++ b/share/libc/string.c
@@ -271,9 +271,19 @@ char *strstr(const char *haystack, const char *needle)
   return NULL;
 }
 
+char __fc_strerror[64];
+static int __fc_strerror_init;
+
 char *strerror(int errnum)
 {
-  return "strerror message by Frama-C";
+#ifdef __FRAMAC__
+  if (!__fc_strerror_init) {
+    Frama_C_make_unknown(__fc_strerror, 63);
+    __fc_strerror[63] = 0;
+    __fc_strerror_init = 1;
+  }
+#endif
+  return __fc_strerror;
 }
 
 /* Warning: read considerations about malloc() in Frama-C */
@@ -307,4 +317,19 @@ char *strndup(const char *s, size_t n)
   return p;
 }
 
+char __fc_strsignal[64];
+static int __fc_strsignal_init;
+
+char *strsignal(int signum)
+{
+#ifdef __FRAMAC__
+  if (!__fc_strsignal_init) {
+    Frama_C_make_unknown(__fc_strsignal, 63);
+    __fc_strsignal[63] = 0;
+    __fc_strsignal_init = 1;
+  }
+#endif
+  return __fc_strsignal;
+}
+
 __POP_FC_STDLIB
-- 
GitLab