18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci#include <linux/types.h> 38c2ecf20Sopenharmony_ci#include <linux/module.h> 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci/* Some of this are builtin function (some are not but could in the future), 68c2ecf20Sopenharmony_ci * so I *must* declare good prototypes for them and then EXPORT them. 78c2ecf20Sopenharmony_ci * The kernel code uses the macro defined by include/linux/string.h, 88c2ecf20Sopenharmony_ci * so I undef macros; the userspace code does not include that and I 98c2ecf20Sopenharmony_ci * add an EXPORT for the glibc one. 108c2ecf20Sopenharmony_ci */ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#undef strlen 138c2ecf20Sopenharmony_ci#undef strstr 148c2ecf20Sopenharmony_ci#undef memcpy 158c2ecf20Sopenharmony_ci#undef memset 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ciextern size_t strlen(const char *); 188c2ecf20Sopenharmony_ciextern void *memmove(void *, const void *, size_t); 198c2ecf20Sopenharmony_ciextern void *memset(void *, int, size_t); 208c2ecf20Sopenharmony_ciextern int printf(const char *, ...); 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci/* If it's not defined, the export is included in lib/string.c.*/ 238c2ecf20Sopenharmony_ci#ifdef __HAVE_ARCH_STRSTR 248c2ecf20Sopenharmony_ciEXPORT_SYMBOL(strstr); 258c2ecf20Sopenharmony_ci#endif 268c2ecf20Sopenharmony_ci 278c2ecf20Sopenharmony_ci#ifndef __x86_64__ 288c2ecf20Sopenharmony_ciextern void *memcpy(void *, const void *, size_t); 298c2ecf20Sopenharmony_ciEXPORT_SYMBOL(memcpy); 308c2ecf20Sopenharmony_ci#endif 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ciEXPORT_SYMBOL(memmove); 338c2ecf20Sopenharmony_ciEXPORT_SYMBOL(memset); 348c2ecf20Sopenharmony_ciEXPORT_SYMBOL(printf); 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci/* Here, instead, I can provide a fake prototype. Yes, someone cares: genksyms. 378c2ecf20Sopenharmony_ci * However, the modules will use the CRC defined *here*, no matter if it is 388c2ecf20Sopenharmony_ci * good; so the versions of these symbols will always match 398c2ecf20Sopenharmony_ci */ 408c2ecf20Sopenharmony_ci#define EXPORT_SYMBOL_PROTO(sym) \ 418c2ecf20Sopenharmony_ci int sym(void); \ 428c2ecf20Sopenharmony_ci EXPORT_SYMBOL(sym); 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ciextern void readdir64(void) __attribute__((weak)); 458c2ecf20Sopenharmony_ciEXPORT_SYMBOL(readdir64); 468c2ecf20Sopenharmony_ciextern void truncate64(void) __attribute__((weak)); 478c2ecf20Sopenharmony_ciEXPORT_SYMBOL(truncate64); 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci#ifdef CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA 508c2ecf20Sopenharmony_ciEXPORT_SYMBOL(vsyscall_ehdr); 518c2ecf20Sopenharmony_ciEXPORT_SYMBOL(vsyscall_end); 528c2ecf20Sopenharmony_ci#endif 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(__errno_location); 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(access); 578c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(open); 588c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(open64); 598c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(close); 608c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(read); 618c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(write); 628c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(dup2); 638c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(__xstat); 648c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(__lxstat); 658c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(__lxstat64); 668c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(__fxstat64); 678c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(lseek); 688c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(lseek64); 698c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(chown); 708c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(fchown); 718c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(truncate); 728c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(ftruncate64); 738c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(utime); 748c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(utimes); 758c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(futimes); 768c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(chmod); 778c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(fchmod); 788c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(rename); 798c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(__xmknod); 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(symlink); 828c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(link); 838c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(unlink); 848c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(readlink); 858c2ecf20Sopenharmony_ci 868c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(mkdir); 878c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(rmdir); 888c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(opendir); 898c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(readdir); 908c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(closedir); 918c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(seekdir); 928c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(telldir); 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(ioctl); 958c2ecf20Sopenharmony_ci 968c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(pread64); 978c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(pwrite64); 988c2ecf20Sopenharmony_ci 998c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(statfs); 1008c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(statfs64); 1018c2ecf20Sopenharmony_ci 1028c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(getuid); 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(fsync); 1058c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(fdatasync); 1068c2ecf20Sopenharmony_ci 1078c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(lstat64); 1088c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(fstat64); 1098c2ecf20Sopenharmony_ciEXPORT_SYMBOL_PROTO(mknod); 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci/* Export symbols used by GCC for the stack protector. */ 1128c2ecf20Sopenharmony_ciextern void __stack_smash_handler(void *) __attribute__((weak)); 1138c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__stack_smash_handler); 1148c2ecf20Sopenharmony_ci 1158c2ecf20Sopenharmony_ciextern long __guard __attribute__((weak)); 1168c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__guard); 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ci#ifdef _FORTIFY_SOURCE 1198c2ecf20Sopenharmony_ciextern int __sprintf_chk(char *str, int flag, size_t strlen, const char *format); 1208c2ecf20Sopenharmony_ciEXPORT_SYMBOL(__sprintf_chk); 1218c2ecf20Sopenharmony_ci#endif 122