[riot-notifications] [RIOT-OS/RIOT] cpu/esp32: fixes the memset optimization problem in esp_wifi/wpa_supplicant (#10801)

Gunar Schorcht notifications at github.com
Fri Jan 18 18:26:26 CET 2019


gschorcht commented on this pull request.



> @@ -595,3 +595,18 @@ void system_wdt_start (void)
     TIMERG0.wdt_wprotect = 0;     /* enable write protection */
     xt_ints_on(BIT(CPU_INUM_WDT));
 }
+
+__attribute__((weak)) void
+_system_prevent_memset_lto(void *const  s, int c, const size_t n)
+{
+    (void) s;
+    (void) c;
+    (void) n;
+}
+
+void *system_secure_memset(void *s, int c, size_t n)
+{
+    memset(s, c, n);
+    _system_prevent_memset_lto(s, c, n);

It's not necessary. The code generated is exactly the same.

w/o `__asm__ __volatile__ ("" : : "r"(s) : "memory");`
```
4008b210 <system_secure_memset>:
4008b210:	004136        	entry	a1, 32
4008b213:	20c440        	or	a12, a4, a4
4008b216:	20b330        	or	a11, a3, a3
4008b219:	20a220        	or	a10, a2, a2
4008b21c:	0464e5        	call8	4008f86c <memset>
4008b21f:	04cd      	mov.n	a12, a4
4008b221:	03bd      	mov.n	a11, a3
4008b223:	02ad      	mov.n	a10, a2
4008b225:	fffe25        	call8	4008b208 <_system_prevent_memset_lto>
4008b228:	f01d      	retw.n
```

with `__asm__ __volatile__ ("" : : "r"(s) : "memory");`
```
4008b210 <system_secure_memset>:
4008b210:	004136        	entry	a1, 32
4008b213:	20c440        	or	a12, a4, a4
4008b216:	20b330        	or	a11, a3, a3
4008b219:	20a220        	or	a10, a2, a2
4008b21c:	0464e5        	call8	4008f86c <memset>
4008b21f:	04cd      	mov.n	a12, a4
4008b221:	03bd      	mov.n	a11, a3
4008b223:	02ad      	mov.n	a10, a2
4008b225:	fffe25        	call8	4008b208 <_system_prevent_memset_lto>
4008b228:	f01d      	retw.n
```

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/10801#discussion_r249123703
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190118/8645ebfb/attachment.html>


More information about the notifications mailing list