Skip to content

Commit b5fa7a2

Browse files
authored
Merge pull request #587 from lrh2000/undef-strings
lkl: Define symbols for string utilities
2 parents 11f5b7e + b18526a commit b5fa7a2

File tree

4 files changed

+42
-3
lines changed

4 files changed

+42
-3
lines changed

arch/lkl/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ LKL_ENTRY_POINTS += \
6161
endif
6262

6363
core-y += arch/lkl/kernel/
64+
core-y += arch/lkl/lib/
6465
core-y += arch/lkl/mm/
6566
core-y += arch/lkl/drivers/
6667

arch/lkl/include/asm/string.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/* use __mem* names to avoid conflict with KASAN's mem* functions. */
99

1010
#define __HAVE_ARCH_MEMCPY
11+
extern void *memcpy(void *dest, const void *src, size_t count);
1112
static inline void *__memcpy(void *dest, const void *src, size_t count)
1213
{
1314
char *tmp = dest;
@@ -24,6 +25,7 @@ static inline void *__memcpy(void *dest, const void *src, size_t count)
2425
}
2526

2627
#define __HAVE_ARCH_MEMSET
28+
extern void *memset(void *s, int c, size_t count);
2729
static inline void *__memset(void *s, int c, size_t count)
2830
{
2931
char *xs = s;
@@ -39,6 +41,7 @@ static inline void *__memset(void *s, int c, size_t count)
3941
}
4042

4143
#define __HAVE_ARCH_MEMMOVE
44+
extern void *memmove(void *dest, const void *src, size_t count);
4245
static inline void *__memmove(void *dest, const void *src, size_t count)
4346
{
4447
char *tmp;
@@ -86,9 +89,6 @@ static inline void *__memmove(void *dest, const void *src, size_t count)
8689
#undef memcpy
8790
#undef memset
8891
#undef memmove
89-
extern void *memset(void *dst, int c, __kernel_size_t count);
90-
extern void *memcpy(void *dst, const void *src, __kernel_size_t count);
91-
extern void *memmove(void *dest, const void *src, size_t count);
9292

9393
#endif /* __SANITIZE_ADDRESS__ */
9494

arch/lkl/lib/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
3+
obj-y += string.o

arch/lkl/lib/string.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// SPDX-License-Identifier: GPL-2.0
2+
3+
#include <linux/string.h>
4+
#include <linux/export.h>
5+
6+
#if !defined(CONFIG_KASAN_GENERIC) || defined(CONFIG_CC_HAS_KASAN_MEMINTRINSIC_PREFIX)
7+
/*
8+
* If CONFIG_KASAN_GENERIC is on but CONFIG_CC_HAS_KASAN_MEMINTRINSIC_PREFIX is
9+
* off, mm/kasan/shadow.c will define the kasan version memcpy and its friends
10+
* for us. We should not do anything, otherwise the symbols will conflict.
11+
*/
12+
13+
#undef memcpy
14+
#undef memset
15+
#undef memmove
16+
17+
__visible void *memcpy(void *dest, const void *src, size_t count)
18+
{
19+
return __memcpy(dest, src, count);
20+
}
21+
EXPORT_SYMBOL(memcpy);
22+
23+
__visible void *memset(void *s, int c, size_t count)
24+
{
25+
return __memset(s, c, count);
26+
}
27+
EXPORT_SYMBOL(memset);
28+
29+
__visible void *memmove(void *dest, const void *src, size_t count)
30+
{
31+
return __memmove(dest, src, count);
32+
}
33+
EXPORT_SYMBOL(memmove);
34+
35+
#endif

0 commit comments

Comments
 (0)