1From 698a6ce88524b727d265b204d648e78d8acb485c Mon Sep 17 00:00:00 2001
2From: Merlin Mathesius <mmathesi@redhat.com>
3Date: Wed, 13 May 2020 11:58:37 -0500
4Subject: [PATCH] Replace builtin strlen that appears to get optimized away
5
6[From https://src.fedoraproject.org/rpms/syslinux/raw/rawhide/f/0006-Replace-builtin-strlen-that-appears-to-get-optimized.patch]
7Signed-off-by: Peter Seiderer <ps.report@gmx.net>
8---
9 dos/string.h | 12 +++++++++++-
10 1 file changed, 11 insertions(+), 1 deletion(-)
11
12diff --git a/dos/string.h b/dos/string.h
13index f648de2d..407d0233 100644
14--- a/dos/string.h
15+++ b/dos/string.h
16@@ -5,12 +5,22 @@
17 #ifndef _STRING_H
18 #define _STRING_H
19
20+#include <stddef.h>
21+
22 /* Standard routines */
23 #define memcpy(a,b,c)	__builtin_memcpy(a,b,c)
24 #define memmove(a,b,c)	__builtin_memmove(a,b,c)
25 #define memset(a,b,c)	__builtin_memset(a,b,c)
26 #define strcpy(a,b)	__builtin_strcpy(a,b)
27-#define strlen(a)	__builtin_strlen(a)
28+#define strlen(a)	inline_strlen(a)
29+
30+/* replacement for builtin strlen that appears to get optimized away */
31+static inline size_t inline_strlen(const char *str)
32+{
33+    size_t l;
34+    for (l = 0; *str++; l++);
35+    return l;
36+}
37
38 /* This only returns true or false */
39 static inline int memcmp(const void *__m1, const void *__m2, unsigned int __n)
40--
412.30.1
42
43