user_syms.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // SPDX-License-Identifier: GPL-2.0
  2. #include <linux/types.h>
  3. #include <linux/module.h>
  4. /* Some of this are builtin function (some are not but could in the future),
  5. * so I *must* declare good prototypes for them and then EXPORT them.
  6. * The kernel code uses the macro defined by include/linux/string.h,
  7. * so I undef macros; the userspace code does not include that and I
  8. * add an EXPORT for the glibc one.
  9. */
  10. #undef strlen
  11. #undef strstr
  12. #undef memcpy
  13. #undef memset
  14. extern size_t strlen(const char *);
  15. extern void *memmove(void *, const void *, size_t);
  16. extern void *memset(void *, int, size_t);
  17. extern int printf(const char *, ...);
  18. /* If it's not defined, the export is included in lib/string.c.*/
  19. #ifdef __HAVE_ARCH_STRSTR
  20. EXPORT_SYMBOL(strstr);
  21. #endif
  22. #ifndef __x86_64__
  23. extern void *memcpy(void *, const void *, size_t);
  24. EXPORT_SYMBOL(memcpy);
  25. #endif
  26. EXPORT_SYMBOL(memmove);
  27. EXPORT_SYMBOL(memset);
  28. EXPORT_SYMBOL(printf);
  29. /* Here, instead, I can provide a fake prototype. Yes, someone cares: genksyms.
  30. * However, the modules will use the CRC defined *here*, no matter if it is
  31. * good; so the versions of these symbols will always match
  32. */
  33. #define EXPORT_SYMBOL_PROTO(sym) \
  34. int sym(void); \
  35. EXPORT_SYMBOL(sym);
  36. extern void readdir64(void) __attribute__((weak));
  37. EXPORT_SYMBOL(readdir64);
  38. extern void truncate64(void) __attribute__((weak));
  39. EXPORT_SYMBOL(truncate64);
  40. #ifdef CONFIG_ARCH_REUSE_HOST_VSYSCALL_AREA
  41. EXPORT_SYMBOL(vsyscall_ehdr);
  42. EXPORT_SYMBOL(vsyscall_end);
  43. #endif
  44. EXPORT_SYMBOL_PROTO(__errno_location);
  45. EXPORT_SYMBOL_PROTO(access);
  46. EXPORT_SYMBOL_PROTO(open);
  47. EXPORT_SYMBOL_PROTO(open64);
  48. EXPORT_SYMBOL_PROTO(close);
  49. EXPORT_SYMBOL_PROTO(read);
  50. EXPORT_SYMBOL_PROTO(write);
  51. EXPORT_SYMBOL_PROTO(dup2);
  52. EXPORT_SYMBOL_PROTO(__xstat);
  53. EXPORT_SYMBOL_PROTO(__lxstat);
  54. EXPORT_SYMBOL_PROTO(__lxstat64);
  55. EXPORT_SYMBOL_PROTO(__fxstat64);
  56. EXPORT_SYMBOL_PROTO(lseek);
  57. EXPORT_SYMBOL_PROTO(lseek64);
  58. EXPORT_SYMBOL_PROTO(chown);
  59. EXPORT_SYMBOL_PROTO(fchown);
  60. EXPORT_SYMBOL_PROTO(truncate);
  61. EXPORT_SYMBOL_PROTO(ftruncate64);
  62. EXPORT_SYMBOL_PROTO(utime);
  63. EXPORT_SYMBOL_PROTO(utimes);
  64. EXPORT_SYMBOL_PROTO(futimes);
  65. EXPORT_SYMBOL_PROTO(chmod);
  66. EXPORT_SYMBOL_PROTO(fchmod);
  67. EXPORT_SYMBOL_PROTO(rename);
  68. EXPORT_SYMBOL_PROTO(__xmknod);
  69. EXPORT_SYMBOL_PROTO(symlink);
  70. EXPORT_SYMBOL_PROTO(link);
  71. EXPORT_SYMBOL_PROTO(unlink);
  72. EXPORT_SYMBOL_PROTO(readlink);
  73. EXPORT_SYMBOL_PROTO(mkdir);
  74. EXPORT_SYMBOL_PROTO(rmdir);
  75. EXPORT_SYMBOL_PROTO(opendir);
  76. EXPORT_SYMBOL_PROTO(readdir);
  77. EXPORT_SYMBOL_PROTO(closedir);
  78. EXPORT_SYMBOL_PROTO(seekdir);
  79. EXPORT_SYMBOL_PROTO(telldir);
  80. EXPORT_SYMBOL_PROTO(ioctl);
  81. EXPORT_SYMBOL_PROTO(pread64);
  82. EXPORT_SYMBOL_PROTO(pwrite64);
  83. EXPORT_SYMBOL_PROTO(statfs);
  84. EXPORT_SYMBOL_PROTO(statfs64);
  85. EXPORT_SYMBOL_PROTO(getuid);
  86. EXPORT_SYMBOL_PROTO(fsync);
  87. EXPORT_SYMBOL_PROTO(fdatasync);
  88. EXPORT_SYMBOL_PROTO(lstat64);
  89. EXPORT_SYMBOL_PROTO(fstat64);
  90. EXPORT_SYMBOL_PROTO(mknod);
  91. /* Export symbols used by GCC for the stack protector. */
  92. extern void __stack_smash_handler(void *) __attribute__((weak));
  93. EXPORT_SYMBOL(__stack_smash_handler);
  94. extern long __guard __attribute__((weak));
  95. EXPORT_SYMBOL(__guard);
  96. #ifdef _FORTIFY_SOURCE
  97. extern int __sprintf_chk(char *str, int flag, size_t strlen, const char *format);
  98. EXPORT_SYMBOL(__sprintf_chk);
  99. #endif