33#include <linux/types.h>
44#include <linux/module.h>
55
6- /* Some of this are builtin function (some are not but could in the future),
7- * so I *must* declare good prototypes for them and then EXPORT them.
8- * The kernel code uses the macro defined by include/linux/string.h,
9- * so I undef macros; the userspace code does not include that and I
10- * add an EXPORT for the glibc one.
6+ /*
7+ * This file exports some critical string functions and compiler
8+ * built-in functions (where calls are emitted by the compiler
9+ * itself that we cannot avoid even in kernel code) to modules.
10+ *
11+ * "_user.c" code that previously used exports here such as hostfs
12+ * really should be considered part of the 'hypervisor' and define
13+ * its own API boundary like hostfs does now; don't add exports to
14+ * this file for such cases.
1115 */
1216
13- #undef strlen
14- #undef strstr
15- #undef memcpy
16- #undef memset
17-
18- extern size_t strlen (const char * );
19- extern void * memmove (void * , const void * , size_t );
20- extern void * memset (void * , int , size_t );
21- extern int printf (const char * , ...);
22-
2317/* If it's not defined, the export is included in lib/string.c.*/
2418#ifdef __HAVE_ARCH_STRSTR
19+ #undef strstr
2520EXPORT_SYMBOL (strstr );
2621#endif
2722
2823#ifndef __x86_64__
24+ #undef memcpy
2925extern void * memcpy (void * , const void * , size_t );
3026EXPORT_SYMBOL (memcpy );
27+ extern void * memmove (void * , const void * , size_t );
3128EXPORT_SYMBOL (memmove );
29+ #undef memset
30+ extern void * memset (void * , int , size_t );
3231EXPORT_SYMBOL (memset );
3332#endif
3433
35- EXPORT_SYMBOL (printf );
36-
37- /* Here, instead, I can provide a fake prototype. Yes, someone cares: genksyms.
38- * However, the modules will use the CRC defined *here*, no matter if it is
39- * good; so the versions of these symbols will always match
40- */
41- #define EXPORT_SYMBOL_PROTO (sym ) \
42- int sym(void); \
43- EXPORT_SYMBOL(sym);
44-
45- extern void readdir64 (void ) __attribute__((weak ));
46- EXPORT_SYMBOL (readdir64 );
47- extern void truncate64 (void ) __attribute__((weak ));
48- EXPORT_SYMBOL (truncate64 );
49-
5034#ifdef CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA
35+ /* needed for __access_ok() */
5136EXPORT_SYMBOL (vsyscall_ehdr );
5237EXPORT_SYMBOL (vsyscall_end );
5338#endif
5439
55- EXPORT_SYMBOL_PROTO (__errno_location );
56-
57- EXPORT_SYMBOL_PROTO (access );
58- EXPORT_SYMBOL_PROTO (open );
59- EXPORT_SYMBOL_PROTO (open64 );
60- EXPORT_SYMBOL_PROTO (close );
61- EXPORT_SYMBOL_PROTO (read );
62- EXPORT_SYMBOL_PROTO (write );
63- EXPORT_SYMBOL_PROTO (dup2 );
64- EXPORT_SYMBOL_PROTO (__xstat );
65- EXPORT_SYMBOL_PROTO (__lxstat );
66- EXPORT_SYMBOL_PROTO (__lxstat64 );
67- EXPORT_SYMBOL_PROTO (__fxstat64 );
68- EXPORT_SYMBOL_PROTO (lseek );
69- EXPORT_SYMBOL_PROTO (lseek64 );
70- EXPORT_SYMBOL_PROTO (chown );
71- EXPORT_SYMBOL_PROTO (fchown );
72- EXPORT_SYMBOL_PROTO (truncate );
73- EXPORT_SYMBOL_PROTO (ftruncate64 );
74- EXPORT_SYMBOL_PROTO (utime );
75- EXPORT_SYMBOL_PROTO (utimes );
76- EXPORT_SYMBOL_PROTO (futimes );
77- EXPORT_SYMBOL_PROTO (chmod );
78- EXPORT_SYMBOL_PROTO (fchmod );
79- EXPORT_SYMBOL_PROTO (rename );
80- EXPORT_SYMBOL_PROTO (__xmknod );
81-
82- EXPORT_SYMBOL_PROTO (symlink );
83- EXPORT_SYMBOL_PROTO (link );
84- EXPORT_SYMBOL_PROTO (unlink );
85- EXPORT_SYMBOL_PROTO (readlink );
86-
87- EXPORT_SYMBOL_PROTO (mkdir );
88- EXPORT_SYMBOL_PROTO (rmdir );
89- EXPORT_SYMBOL_PROTO (opendir );
90- EXPORT_SYMBOL_PROTO (readdir );
91- EXPORT_SYMBOL_PROTO (closedir );
92- EXPORT_SYMBOL_PROTO (seekdir );
93- EXPORT_SYMBOL_PROTO (telldir );
94-
95- EXPORT_SYMBOL_PROTO (ioctl );
96-
97- EXPORT_SYMBOL_PROTO (pread64 );
98- EXPORT_SYMBOL_PROTO (pwrite64 );
99-
100- EXPORT_SYMBOL_PROTO (statfs );
101- EXPORT_SYMBOL_PROTO (statfs64 );
102-
103- EXPORT_SYMBOL_PROTO (getuid );
104-
105- EXPORT_SYMBOL_PROTO (fsync );
106- EXPORT_SYMBOL_PROTO (fdatasync );
107-
108- EXPORT_SYMBOL_PROTO (lstat64 );
109- EXPORT_SYMBOL_PROTO (fstat64 );
110- EXPORT_SYMBOL_PROTO (mknod );
111-
11240/* Export symbols used by GCC for the stack protector. */
11341extern void __stack_smash_handler (void * ) __attribute__((weak ));
11442EXPORT_SYMBOL (__stack_smash_handler );
@@ -117,6 +45,6 @@ extern long __guard __attribute__((weak));
11745EXPORT_SYMBOL (__guard );
11846
11947#ifdef _FORTIFY_SOURCE
120- extern int __sprintf_chk (char * str , int flag , size_t strlen , const char * format );
48+ extern int __sprintf_chk (char * str , int flag , size_t len , const char * format );
12149EXPORT_SYMBOL (__sprintf_chk );
12250#endif
0 commit comments