@amxts/core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (247) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +162 -0
  3. package/README.ru.md +162 -0
  4. package/amxmodx/base/include/amxconst.inc +594 -0
  5. package/amxmodx/base/include/amxmisc.inc +902 -0
  6. package/amxmodx/base/include/amxmodx.inc +3447 -0
  7. package/amxmodx/base/include/amxmodx_version.inc +20 -0
  8. package/amxmodx/base/include/cellarray.inc +525 -0
  9. package/amxmodx/base/include/cellstack.inc +166 -0
  10. package/amxmodx/base/include/celltrie.inc +412 -0
  11. package/amxmodx/base/include/core.inc +202 -0
  12. package/amxmodx/base/include/csstats.inc +298 -0
  13. package/amxmodx/base/include/csstats_const.inc +29 -0
  14. package/amxmodx/base/include/cstrike.inc +1287 -0
  15. package/amxmodx/base/include/cstrike_const.inc +521 -0
  16. package/amxmodx/base/include/csx.inc +259 -0
  17. package/amxmodx/base/include/cvars.inc +547 -0
  18. package/amxmodx/base/include/datapack.inc +161 -0
  19. package/amxmodx/base/include/dbi.inc +154 -0
  20. package/amxmodx/base/include/dodconst.inc +152 -0
  21. package/amxmodx/base/include/dodfun.inc +152 -0
  22. package/amxmodx/base/include/dodstats.inc +69 -0
  23. package/amxmodx/base/include/dodx.inc +161 -0
  24. package/amxmodx/base/include/engine.inc +1343 -0
  25. package/amxmodx/base/include/engine_const.inc +310 -0
  26. package/amxmodx/base/include/engine_stocks.inc +248 -0
  27. package/amxmodx/base/include/esf.inc +70 -0
  28. package/amxmodx/base/include/esf_const.inc +74 -0
  29. package/amxmodx/base/include/fakemeta.inc +1127 -0
  30. package/amxmodx/base/include/fakemeta_const.inc +793 -0
  31. package/amxmodx/base/include/fakemeta_stocks.inc +395 -0
  32. package/amxmodx/base/include/fakemeta_util.inc +882 -0
  33. package/amxmodx/base/include/file.inc +666 -0
  34. package/amxmodx/base/include/float.inc +422 -0
  35. package/amxmodx/base/include/fun.inc +333 -0
  36. package/amxmodx/base/include/gameconfig.inc +93 -0
  37. package/amxmodx/base/include/geoip.inc +264 -0
  38. package/amxmodx/base/include/ham_const.inc +4352 -0
  39. package/amxmodx/base/include/hamsandwich.inc +439 -0
  40. package/amxmodx/base/include/hlsdk_const.inc +808 -0
  41. package/amxmodx/base/include/json.inc +777 -0
  42. package/amxmodx/base/include/lang.inc +119 -0
  43. package/amxmodx/base/include/message_const.inc +1130 -0
  44. package/amxmodx/base/include/message_stocks.inc +161 -0
  45. package/amxmodx/base/include/messages.inc +604 -0
  46. package/amxmodx/base/include/newmenus.inc +387 -0
  47. package/amxmodx/base/include/ns.inc +754 -0
  48. package/amxmodx/base/include/ns_const.inc +196 -0
  49. package/amxmodx/base/include/nvault.inc +154 -0
  50. package/amxmodx/base/include/regex.inc +348 -0
  51. package/amxmodx/base/include/sockets.inc +183 -0
  52. package/amxmodx/base/include/sorting.inc +107 -0
  53. package/amxmodx/base/include/sqlx.inc +582 -0
  54. package/amxmodx/base/include/string.inc +786 -0
  55. package/amxmodx/base/include/string_const.inc +156 -0
  56. package/amxmodx/base/include/string_stocks.inc +325 -0
  57. package/amxmodx/base/include/textparse_ini.inc +214 -0
  58. package/amxmodx/base/include/textparse_smc.inc +261 -0
  59. package/amxmodx/base/include/tfcconst.inc +84 -0
  60. package/amxmodx/base/include/tfcstats.inc +62 -0
  61. package/amxmodx/base/include/tfcx.inc +148 -0
  62. package/amxmodx/base/include/time.inc +118 -0
  63. package/amxmodx/base/include/tsconst.inc +154 -0
  64. package/amxmodx/base/include/tsfun.inc +198 -0
  65. package/amxmodx/base/include/tsstats.inc +65 -0
  66. package/amxmodx/base/include/tsx.inc +88 -0
  67. package/amxmodx/base/include/vault.inc +60 -0
  68. package/amxmodx/base/include/vector.inc +131 -0
  69. package/amxmodx/base/include/xs.inc +1570 -0
  70. package/as/amxts.d.ts +153 -0
  71. package/as/constants.ts +4730 -0
  72. package/as/effects.ts +1449 -0
  73. package/as/entities.ts +5482 -0
  74. package/as/events.ts +3054 -0
  75. package/as/facade.ts +4639 -0
  76. package/as/flags.ts +299 -0
  77. package/as/fs.ts +287 -0
  78. package/as/hooks.ts +18536 -0
  79. package/as/kit.ts +25 -0
  80. package/as/lib/check.ts +86 -0
  81. package/as/modules/http.ts +184 -0
  82. package/as/natives.ts +11845 -0
  83. package/as/os.ts +30 -0
  84. package/as/promise.ts +1392 -0
  85. package/as/promise.types.d.ts +82 -0
  86. package/as/remote.ts +288 -0
  87. package/as/tsconfig.json +22 -0
  88. package/as/vector.ts +65 -0
  89. package/bin/amxts.mjs +10 -0
  90. package/includes/menu_core.inc +355 -0
  91. package/includes/order.txt +54 -0
  92. package/includes/sources.json +27 -0
  93. package/includes/universal_config.inc +355 -0
  94. package/lint/oxlint-plugin.mjs +77 -0
  95. package/node_modules/assemblyscript/LICENSE +201 -0
  96. package/node_modules/assemblyscript/NOTICE +93 -0
  97. package/node_modules/assemblyscript/package.json +63 -0
  98. package/node_modules/assemblyscript/std/README.md +6 -0
  99. package/node_modules/assemblyscript/std/assembly/array.ts +526 -0
  100. package/node_modules/assemblyscript/std/assembly/arraybuffer.ts +77 -0
  101. package/node_modules/assemblyscript/std/assembly/atomics.ts +127 -0
  102. package/node_modules/assemblyscript/std/assembly/bindings/asyncify.ts +16 -0
  103. package/node_modules/assemblyscript/std/assembly/bindings/dom.ts +291 -0
  104. package/node_modules/assemblyscript/std/assembly/bindings/node.ts +6 -0
  105. package/node_modules/assemblyscript/std/assembly/builtins.ts +2631 -0
  106. package/node_modules/assemblyscript/std/assembly/compat.ts +2 -0
  107. package/node_modules/assemblyscript/std/assembly/console.ts +42 -0
  108. package/node_modules/assemblyscript/std/assembly/crypto.ts +9 -0
  109. package/node_modules/assemblyscript/std/assembly/dataview.ts +181 -0
  110. package/node_modules/assemblyscript/std/assembly/date.ts +373 -0
  111. package/node_modules/assemblyscript/std/assembly/diagnostics.ts +11 -0
  112. package/node_modules/assemblyscript/std/assembly/error.ts +44 -0
  113. package/node_modules/assemblyscript/std/assembly/function.ts +38 -0
  114. package/node_modules/assemblyscript/std/assembly/index.d.ts +2822 -0
  115. package/node_modules/assemblyscript/std/assembly/iterator.ts +35 -0
  116. package/node_modules/assemblyscript/std/assembly/map.ts +260 -0
  117. package/node_modules/assemblyscript/std/assembly/math.ts +3289 -0
  118. package/node_modules/assemblyscript/std/assembly/memory.ts +123 -0
  119. package/node_modules/assemblyscript/std/assembly/number.ts +388 -0
  120. package/node_modules/assemblyscript/std/assembly/object.ts +36 -0
  121. package/node_modules/assemblyscript/std/assembly/performance.ts +9 -0
  122. package/node_modules/assemblyscript/std/assembly/polyfills.ts +27 -0
  123. package/node_modules/assemblyscript/std/assembly/process.ts +50 -0
  124. package/node_modules/assemblyscript/std/assembly/reference.ts +48 -0
  125. package/node_modules/assemblyscript/std/assembly/regexp.ts +12 -0
  126. package/node_modules/assemblyscript/std/assembly/rt/README.md +83 -0
  127. package/node_modules/assemblyscript/std/assembly/rt/common.ts +81 -0
  128. package/node_modules/assemblyscript/std/assembly/rt/index-incremental.ts +2 -0
  129. package/node_modules/assemblyscript/std/assembly/rt/index-minimal.ts +2 -0
  130. package/node_modules/assemblyscript/std/assembly/rt/index-stub.ts +1 -0
  131. package/node_modules/assemblyscript/std/assembly/rt/index.d.ts +37 -0
  132. package/node_modules/assemblyscript/std/assembly/rt/itcms.ts +419 -0
  133. package/node_modules/assemblyscript/std/assembly/rt/rtrace.ts +15 -0
  134. package/node_modules/assemblyscript/std/assembly/rt/stub.ts +133 -0
  135. package/node_modules/assemblyscript/std/assembly/rt/tcms.ts +254 -0
  136. package/node_modules/assemblyscript/std/assembly/rt/tlsf.ts +592 -0
  137. package/node_modules/assemblyscript/std/assembly/rt.ts +87 -0
  138. package/node_modules/assemblyscript/std/assembly/set.ts +220 -0
  139. package/node_modules/assemblyscript/std/assembly/shared/feature.ts +65 -0
  140. package/node_modules/assemblyscript/std/assembly/shared/runtime.ts +11 -0
  141. package/node_modules/assemblyscript/std/assembly/shared/target.ts +11 -0
  142. package/node_modules/assemblyscript/std/assembly/shared/tsconfig.json +11 -0
  143. package/node_modules/assemblyscript/std/assembly/shared/typeinfo.ts +72 -0
  144. package/node_modules/assemblyscript/std/assembly/staticarray.ts +401 -0
  145. package/node_modules/assemblyscript/std/assembly/string.ts +847 -0
  146. package/node_modules/assemblyscript/std/assembly/symbol.ts +114 -0
  147. package/node_modules/assemblyscript/std/assembly/table.ts +16 -0
  148. package/node_modules/assemblyscript/std/assembly/tsconfig.json +6 -0
  149. package/node_modules/assemblyscript/std/assembly/typedarray.ts +1945 -0
  150. package/node_modules/assemblyscript/std/assembly/uri.ts +17 -0
  151. package/node_modules/assemblyscript/std/assembly/util/bytes.ts +107 -0
  152. package/node_modules/assemblyscript/std/assembly/util/casemap.ts +497 -0
  153. package/node_modules/assemblyscript/std/assembly/util/error.ts +54 -0
  154. package/node_modules/assemblyscript/std/assembly/util/hash.ts +117 -0
  155. package/node_modules/assemblyscript/std/assembly/util/math.ts +1922 -0
  156. package/node_modules/assemblyscript/std/assembly/util/memory.ts +290 -0
  157. package/node_modules/assemblyscript/std/assembly/util/number.ts +873 -0
  158. package/node_modules/assemblyscript/std/assembly/util/sort.ts +313 -0
  159. package/node_modules/assemblyscript/std/assembly/util/string.ts +1202 -0
  160. package/node_modules/assemblyscript/std/assembly/util/uri.ts +275 -0
  161. package/node_modules/assemblyscript/std/assembly/vector.ts +4 -0
  162. package/node_modules/assemblyscript/std/assembly.json +16 -0
  163. package/node_modules/assemblyscript/std/portable/index.d.ts +462 -0
  164. package/node_modules/assemblyscript/std/portable/index.js +416 -0
  165. package/node_modules/assemblyscript/std/portable.json +11 -0
  166. package/node_modules/assemblyscript/std/types/assembly/index.d.ts +1 -0
  167. package/node_modules/assemblyscript/std/types/assembly/package.json +3 -0
  168. package/node_modules/assemblyscript/std/types/portable/index.d.ts +1 -0
  169. package/node_modules/assemblyscript/std/types/portable/package.json +3 -0
  170. package/node_modules/assemblyscript/tsconfig-base.json +13 -0
  171. package/package.json +112 -0
  172. package/runtime/deps/assemblyscript/LICENSE +201 -0
  173. package/runtime/deps/assemblyscript/NOTICE +93 -0
  174. package/runtime/deps/assemblyscript/bin/asc.js +35 -0
  175. package/runtime/deps/assemblyscript/dist/asc.js +25035 -0
  176. package/runtime/deps/assemblyscript/dist/assemblyscript.js +337 -0
  177. package/runtime/deps/assemblyscript/node_modules/binaryen/LICENSE +201 -0
  178. package/runtime/deps/assemblyscript/node_modules/binaryen/index.js +28905 -0
  179. package/runtime/deps/assemblyscript/node_modules/binaryen/package.json +50 -0
  180. package/runtime/deps/assemblyscript/node_modules/long/LICENSE +202 -0
  181. package/runtime/deps/assemblyscript/node_modules/long/index.js +1581 -0
  182. package/runtime/deps/assemblyscript/node_modules/long/package.json +58 -0
  183. package/runtime/deps/assemblyscript/package.json +114 -0
  184. package/runtime/host/amxts.inc +85 -0
  185. package/runtime/licenses/AMXX-LICENSE.txt +34 -0
  186. package/runtime/licenses/AssemblyScript-LICENSE +201 -0
  187. package/runtime/licenses/AssemblyScript-NOTICE +93 -0
  188. package/runtime/licenses/Binaryen-LICENSE +201 -0
  189. package/runtime/licenses/Bun-LICENSE.md +84 -0
  190. package/runtime/licenses/GPL-3.0.txt +674 -0
  191. package/runtime/licenses/LLVM-LICENSE.TXT +279 -0
  192. package/runtime/licenses/README.md +25 -0
  193. package/runtime/licenses/WAMR-LICENSE +219 -0
  194. package/runtime/natives.txt +1095 -0
  195. package/runtime/patches/README.md +59 -0
  196. package/runtime/patches/assemblyscript-0.28.20-amxts.patch +14174 -0
  197. package/runtime/patches/wamr-2.4.5-amxts.patch +364 -0
  198. package/scripts/apply-docs.ts +508 -0
  199. package/scripts/asc.ts +27 -0
  200. package/scripts/auto-imports.ts +258 -0
  201. package/scripts/build-wasm.ts +595 -0
  202. package/scripts/check.ts +93 -0
  203. package/scripts/compile-cache.ts +179 -0
  204. package/scripts/compile.ts +401 -0
  205. package/scripts/docker-server.ts +73 -0
  206. package/scripts/docs/as/amxts.ts +210 -0
  207. package/scripts/docs/as/effects.ts +1684 -0
  208. package/scripts/docs/as/facade.ts +3302 -0
  209. package/scripts/docs/as/fs.ts +173 -0
  210. package/scripts/docs/as/lib/check.ts +68 -0
  211. package/scripts/docs/as/modules/http.ts +66 -0
  212. package/scripts/docs/as/os.ts +16 -0
  213. package/scripts/docs/as/promise.ts +132 -0
  214. package/scripts/docs/as/promise.types.ts +63 -0
  215. package/scripts/docs/as/vector.ts +48 -0
  216. package/scripts/docs/entities.ts +2338 -0
  217. package/scripts/docs/events.ts +245 -0
  218. package/scripts/docs/game.ts +497 -0
  219. package/scripts/docs/messages.ts +148 -0
  220. package/scripts/file-contents.ts +74 -0
  221. package/scripts/includes.ts +134 -0
  222. package/scripts/player-fields.ts +866 -0
  223. package/scripts/plugin-cache.ts +92 -0
  224. package/scripts/plugin-natives.ts +1157 -0
  225. package/scripts/prebuilt.ts +268 -0
  226. package/scripts/prepare.ts +134 -0
  227. package/scripts/project.ts +973 -0
  228. package/scripts/run.ts +28 -0
  229. package/scripts/shared-modules.ts +906 -0
  230. package/scripts/system.ts +33 -0
  231. package/scripts/tracked-fs.ts +115 -0
  232. package/scripts/typed-configs.ts +788 -0
  233. package/scripts/ui.ts +77 -0
  234. package/src/cli-api.mjs +175 -0
  235. package/src/parser/include-parser.ts +506 -0
  236. package/src/system.mjs +155 -0
  237. package/src/testing/compile-cache.ts +31 -0
  238. package/src/testing/compile.ts +222 -0
  239. package/src/testing/coroutines.ts +191 -0
  240. package/src/testing/index.ts +39 -0
  241. package/src/testing/kits.ts +55 -0
  242. package/src/testing/memory.ts +125 -0
  243. package/src/testing/natives.ts +925 -0
  244. package/src/testing/server.ts +1874 -0
  245. package/src/testing/setup.ts +63 -0
  246. package/src/testing/tables.ts +139 -0
  247. package/src/types.ts +51 -0
@@ -0,0 +1,364 @@
1
+ diff --git a/core/iwasm/aot/aot_loader.c b/core/iwasm/aot/aot_loader.c
2
+ index 771ef87..7bdb74d 100644
3
+ --- a/core/iwasm/aot/aot_loader.c
4
+ +++ b/core/iwasm/aot/aot_loader.c
5
+ @@ -26,6 +26,50 @@
6
+ #define YMM_PLT_PREFIX "__ymm@"
7
+ #define XMM_PLT_PREFIX "__xmm@"
8
+ #define REAL_PLT_PREFIX "__real@"
9
+ +/* amxts: on i386 LLVM emits the float constant pool symbol with one
10
+ + underscore, so `__real@40400000` arrives as `_real@40400000` and the prefix
11
+ + check below never matched. A plugin then fails to load with
12
+ + "resolve symbol _real@... failed" the moment it uses a float constant —
13
+ + which, where positions and velocities are vectors, is immediately. */
14
+ +#define REAL_PLT_PREFIX_I386 "_real@"
15
+ +
16
+ +static uint32
17
+ +real_plt_prefix_len(const char *symbol)
18
+ +{
19
+ + if (!strncmp(symbol, REAL_PLT_PREFIX, strlen(REAL_PLT_PREFIX)))
20
+ + return (uint32)strlen(REAL_PLT_PREFIX);
21
+ + if (!strncmp(symbol, REAL_PLT_PREFIX_I386, strlen(REAL_PLT_PREFIX_I386)))
22
+ + return (uint32)strlen(REAL_PLT_PREFIX_I386);
23
+ + return 0;
24
+ +}
25
+ +
26
+ +/* amxts: the same one-underscore spelling for the vector constant pools. Two
27
+ + f64 constants LLVM packs into one SSE load arrive as
28
+ + `_xmm@40200000000000004022000000000000`; with plugin numbers f64
29
+ + (JavaScript's number) a plugin easily has several, and without this it
30
+ + fails to load with "resolve symbol _xmm@... failed". */
31
+ +#define XMM_PLT_PREFIX_I386 "_xmm@"
32
+ +#define YMM_PLT_PREFIX_I386 "_ymm@"
33
+ +
34
+ +static uint32
35
+ +xmm_plt_prefix_len(const char *symbol)
36
+ +{
37
+ + if (!strncmp(symbol, XMM_PLT_PREFIX, strlen(XMM_PLT_PREFIX)))
38
+ + return (uint32)strlen(XMM_PLT_PREFIX);
39
+ + if (!strncmp(symbol, XMM_PLT_PREFIX_I386, strlen(XMM_PLT_PREFIX_I386)))
40
+ + return (uint32)strlen(XMM_PLT_PREFIX_I386);
41
+ + return 0;
42
+ +}
43
+ +
44
+ +static uint32
45
+ +ymm_plt_prefix_len(const char *symbol)
46
+ +{
47
+ + if (!strncmp(symbol, YMM_PLT_PREFIX, strlen(YMM_PLT_PREFIX)))
48
+ + return (uint32)strlen(YMM_PLT_PREFIX);
49
+ + if (!strncmp(symbol, YMM_PLT_PREFIX_I386, strlen(YMM_PLT_PREFIX_I386)))
50
+ + return (uint32)strlen(YMM_PLT_PREFIX_I386);
51
+ + return 0;
52
+ +}
53
+
54
+ static void
55
+ set_error_buf(char *error_buf, uint32 error_buf_size, const char *string)
56
+ @@ -3303,14 +3347,14 @@ do_text_relocation(AOTModule *module, AOTRelocationGroup *group,
57
+ sections. We simply create extra plt data, parse the values from
58
+ the symbols and stored them into the extra plt data. */
59
+ else if (!strcmp(group->section_name, ".text")
60
+ - && !strncmp(symbol, YMM_PLT_PREFIX, strlen(YMM_PLT_PREFIX))
61
+ - && strlen(symbol) == strlen(YMM_PLT_PREFIX) + 64) {
62
+ + && ymm_plt_prefix_len(symbol)
63
+ + && strlen(symbol) == ymm_plt_prefix_len(symbol) + 64) {
64
+ char ymm_buf[17] = { 0 };
65
+
66
+ symbol_addr = module->extra_plt_data + ymm_plt_index * 32;
67
+ for (j = 0; j < 4; j++) {
68
+ bh_memcpy_s(ymm_buf, sizeof(ymm_buf),
69
+ - symbol + strlen(YMM_PLT_PREFIX) + 48 - 16 * j, 16);
70
+ + symbol + ymm_plt_prefix_len(symbol) + 48 - 16 * j, 16);
71
+ if (!str2uint64(ymm_buf,
72
+ (uint64 *)((uint8 *)symbol_addr + 8 * j))) {
73
+ set_error_buf_v(error_buf, error_buf_size,
74
+ @@ -3321,15 +3365,15 @@ do_text_relocation(AOTModule *module, AOTRelocationGroup *group,
75
+ ymm_plt_index++;
76
+ }
77
+ else if (!strcmp(group->section_name, ".text")
78
+ - && !strncmp(symbol, XMM_PLT_PREFIX, strlen(XMM_PLT_PREFIX))
79
+ - && strlen(symbol) == strlen(XMM_PLT_PREFIX) + 32) {
80
+ + && xmm_plt_prefix_len(symbol)
81
+ + && strlen(symbol) == xmm_plt_prefix_len(symbol) + 32) {
82
+ char xmm_buf[17] = { 0 };
83
+
84
+ symbol_addr = module->extra_plt_data + module->ymm_plt_count * 32
85
+ + xmm_plt_index * 16;
86
+ for (j = 0; j < 2; j++) {
87
+ bh_memcpy_s(xmm_buf, sizeof(xmm_buf),
88
+ - symbol + strlen(XMM_PLT_PREFIX) + 16 - 16 * j, 16);
89
+ + symbol + xmm_plt_prefix_len(symbol) + 16 - 16 * j, 16);
90
+ if (!str2uint64(xmm_buf,
91
+ (uint64 *)((uint8 *)symbol_addr + 8 * j))) {
92
+ set_error_buf_v(error_buf, error_buf_size,
93
+ @@ -3340,14 +3384,14 @@ do_text_relocation(AOTModule *module, AOTRelocationGroup *group,
94
+ xmm_plt_index++;
95
+ }
96
+ else if (!strcmp(group->section_name, ".text")
97
+ - && !strncmp(symbol, REAL_PLT_PREFIX, strlen(REAL_PLT_PREFIX))
98
+ - && strlen(symbol) == strlen(REAL_PLT_PREFIX) + 16) {
99
+ + && real_plt_prefix_len(symbol)
100
+ + && strlen(symbol) == real_plt_prefix_len(symbol) + 16) {
101
+ char real_buf[17] = { 0 };
102
+
103
+ symbol_addr = module->extra_plt_data + module->ymm_plt_count * 32
104
+ + module->xmm_plt_count * 16 + real_plt_index * 8;
105
+ bh_memcpy_s(real_buf, sizeof(real_buf),
106
+ - symbol + strlen(REAL_PLT_PREFIX), 16);
107
+ + symbol + real_plt_prefix_len(symbol), 16);
108
+ if (!str2uint64(real_buf, (uint64 *)symbol_addr)) {
109
+ set_error_buf_v(error_buf, error_buf_size,
110
+ "resolve symbol %s failed", symbol);
111
+ @@ -3356,15 +3400,15 @@ do_text_relocation(AOTModule *module, AOTRelocationGroup *group,
112
+ real_plt_index++;
113
+ }
114
+ else if (!strcmp(group->section_name, ".text")
115
+ - && !strncmp(symbol, REAL_PLT_PREFIX, strlen(REAL_PLT_PREFIX))
116
+ - && strlen(symbol) == strlen(REAL_PLT_PREFIX) + 8) {
117
+ + && real_plt_prefix_len(symbol)
118
+ + && strlen(symbol) == real_plt_prefix_len(symbol) + 8) {
119
+ char float_buf[9] = { 0 };
120
+
121
+ symbol_addr = module->extra_plt_data + module->ymm_plt_count * 32
122
+ + module->xmm_plt_count * 16
123
+ + module->real_plt_count * 8 + float_plt_index * 4;
124
+ bh_memcpy_s(float_buf, sizeof(float_buf),
125
+ - symbol + strlen(REAL_PLT_PREFIX), 8);
126
+ + symbol + real_plt_prefix_len(symbol), 8);
127
+ if (!str2uint32(float_buf, (uint32 *)symbol_addr)) {
128
+ set_error_buf_v(error_buf, error_buf_size,
129
+ "resolve symbol %s failed", symbol);
130
+ @@ -3635,24 +3679,22 @@ load_relocation_section(const uint8 *buf, const uint8 *buf_end,
131
+ if (group_name_len == strlen(".text") + 1
132
+ && !strncmp(group_name, ".text", strlen(".text"))) {
133
+ /* aot compiler emits string with '\0' since 2.0.0 */
134
+ - if (symbol_name_len == strlen(YMM_PLT_PREFIX) + 64 + 1
135
+ - && !strncmp(symbol_name, YMM_PLT_PREFIX,
136
+ - strlen(YMM_PLT_PREFIX))) {
137
+ + if (ymm_plt_prefix_len(symbol_name)
138
+ + && symbol_name_len == ymm_plt_prefix_len(symbol_name) + 64 + 1) {
139
+ module->ymm_plt_count++;
140
+ }
141
+ - else if (symbol_name_len == strlen(XMM_PLT_PREFIX) + 32 + 1
142
+ - && !strncmp(symbol_name, XMM_PLT_PREFIX,
143
+ - strlen(XMM_PLT_PREFIX))) {
144
+ + else if (xmm_plt_prefix_len(symbol_name)
145
+ + && symbol_name_len == xmm_plt_prefix_len(symbol_name) + 32 + 1) {
146
+ module->xmm_plt_count++;
147
+ }
148
+ - else if (symbol_name_len == strlen(REAL_PLT_PREFIX) + 16 + 1
149
+ - && !strncmp(symbol_name, REAL_PLT_PREFIX,
150
+ - strlen(REAL_PLT_PREFIX))) {
151
+ + else if (real_plt_prefix_len(symbol_name)
152
+ + && symbol_name_len
153
+ + == real_plt_prefix_len(symbol_name) + 16 + 1) {
154
+ module->real_plt_count++;
155
+ }
156
+ - else if (symbol_name_len >= strlen(REAL_PLT_PREFIX) + 8 + 1
157
+ - && !strncmp(symbol_name, REAL_PLT_PREFIX,
158
+ - strlen(REAL_PLT_PREFIX))) {
159
+ + else if (real_plt_prefix_len(symbol_name)
160
+ + && symbol_name_len
161
+ + >= real_plt_prefix_len(symbol_name) + 8 + 1) {
162
+ module->float_plt_count++;
163
+ }
164
+ }
165
+ diff --git a/core/iwasm/aot/arch/aot_reloc_x86_32.c b/core/iwasm/aot/arch/aot_reloc_x86_32.c
166
+ index f7f2421..89ba8b9 100644
167
+ --- a/core/iwasm/aot/arch/aot_reloc_x86_32.c
168
+ +++ b/core/iwasm/aot/arch/aot_reloc_x86_32.c
169
+ @@ -62,6 +62,10 @@ static int64 __stdcall __allrem(int64 a, int64 b)
170
+ {
171
+ return a % b;
172
+ }
173
+ +static uint64 __stdcall __aullrem(uint64 a, uint64 b)
174
+ +{
175
+ + return a % b;
176
+ +}
177
+ #endif /* !defined(_WIN32) && !defined(_WIN32_) */
178
+
179
+ /* clang-format off */
180
+ @@ -75,7 +79,16 @@ static SymbolMap target_sym_map[] = {
181
+ #if defined(_WIN32) || defined(_WIN32_)
182
+ REG_SYM(__aulldiv),
183
+ REG_SYM(__alldiv),
184
+ - REG_SYM(__allrem)
185
+ + REG_SYM(__allrem),
186
+ + REG_SYM(__aullrem),
187
+ + /* amxts: LLVM's i386 code asks for the 64-bit division helpers with one
188
+ + underscore - `_alldiv` - the same spelling as `_real@` and `_xmm@` in
189
+ + aot_loader.c. Dividing an i64 (Date's milliseconds) failed to load
190
+ + with "resolve symbol _alldiv failed". */
191
+ + { "_aulldiv", (void *)__aulldiv },
192
+ + { "_alldiv", (void *)__alldiv },
193
+ + { "_allrem", (void *)__allrem },
194
+ + { "_aullrem", (void *)__aullrem },
195
+ #endif /* defined(_WIN32) || defined(_WIN32_) */
196
+ };
197
+ /* clang-format on */
198
+ diff --git a/core/iwasm/common/wasm_native.c b/core/iwasm/common/wasm_native.c
199
+ index 060bb2c..28c182d 100644
200
+ --- a/core/iwasm/common/wasm_native.c
201
+ +++ b/core/iwasm/common/wasm_native.c
202
+ @@ -235,12 +235,15 @@ wasm_native_resolve_symbol(const char *module_name, const char *field_name,
203
+ if (signature && signature[0] != '\0') {
204
+ /* signature is not empty, check its format */
205
+ if (!func_type || !check_symbol_signature(func_type, signature)) {
206
+ -#if WASM_ENABLE_WAMR_COMPILER == 0
207
+ - /* Output warning except running aot compiler */
208
+ + /* amxts: this warning used to be compiled out of the aot
209
+ + compiler. A signature only reaches here because someone
210
+ + registered it, so a mismatch is a mistake worth hearing
211
+ + about: the compiler quietly drops that import to the
212
+ + generic aot_invoke_native path, 28 ns a call instead of
213
+ + 2, and nothing in the build says so. */
214
+ LOG_WARNING("failed to check signature '%s' and resolve "
215
+ "pointer params for import function (%s, %s)\n",
216
+ signature, module_name, field_name);
217
+ -#endif
218
+ return NULL;
219
+ }
220
+ else
221
+ diff --git a/wamr-compiler/CMakeLists.txt b/wamr-compiler/CMakeLists.txt
222
+ index 8ee61ca..5a496cd 100644
223
+ --- a/wamr-compiler/CMakeLists.txt
224
+ +++ b/wamr-compiler/CMakeLists.txt
225
+ @@ -167,7 +167,35 @@ if (NOT WAMR_BUILD_WITH_CUSTOM_LLVM)
226
+ set (CMAKE_PREFIX_PATH "${LLVM_SRC_ROOT}/build;${CMAKE_PREFIX_PATH}")
227
+ endif ()
228
+
229
+ +# LLVM's exported targets reference LibXml2::LibXml2 through
230
+ +# LLVMWindowsManifest, which wamrc does not use. A stub keeps CMake happy
231
+ +# without requiring libxml2 to be installed.
232
+ +if (NOT TARGET LibXml2::LibXml2)
233
+ + add_library(LibXml2::LibXml2 INTERFACE IMPORTED)
234
+ +endif()
235
+ +
236
+ find_package(LLVM REQUIRED CONFIG)
237
+ +
238
+ +# The prebuilt LLVM was linked on a machine with Visual Studio 2019 and its
239
+ +# exported targets carry that absolute path to the DIA SDK's diaguids.lib,
240
+ +# which is only needed for reading PDBs — something wamrc never does. Point it
241
+ +# at whatever DIA SDK exists here, or drop it.
242
+ +if (WIN32 AND TARGET LLVMDebugInfoPDB)
243
+ + file (GLOB_RECURSE AMXTS_DIAGUIDS
244
+ + "C:/Program Files (x86)/Microsoft Visual Studio/*/*/DIA SDK/lib/amd64/diaguids.lib")
245
+ + set (AMXTS_DIAGUIDS_FIRST "")
246
+ + if (AMXTS_DIAGUIDS)
247
+ + list (GET AMXTS_DIAGUIDS 0 AMXTS_DIAGUIDS_FIRST)
248
+ + endif ()
249
+ + if (AMXTS_DIAGUIDS_FIRST)
250
+ + message (STATUS "amxts: using DIA SDK at ${AMXTS_DIAGUIDS_FIRST}")
251
+ + set_property (TARGET LLVMDebugInfoPDB PROPERTY
252
+ + INTERFACE_LINK_LIBRARIES "${AMXTS_DIAGUIDS_FIRST}")
253
+ + else ()
254
+ + message (STATUS "amxts: no DIA SDK found, unlinking LLVMDebugInfoPDB")
255
+ + set_property (TARGET LLVMDebugInfoPDB PROPERTY INTERFACE_LINK_LIBRARIES "")
256
+ + endif ()
257
+ +endif ()
258
+ include_directories(${LLVM_INCLUDE_DIRS})
259
+ add_definitions(${LLVM_DEFINITIONS})
260
+
261
+ diff --git a/wamr-compiler/main.c b/wamr-compiler/main.c
262
+ index 62b0dfb..de657a4 100644
263
+ --- a/wamr-compiler/main.c
264
+ +++ b/wamr-compiler/main.c
265
+ @@ -105,6 +105,56 @@ unregister_and_unload_native_libs(uint32 native_lib_count,
266
+ }
267
+ #endif
268
+
269
+ +/* amxts: hand the compiler the host's native signatures. aot_emit_function.c
270
+ + emits a direct call to func_ptrs[idx] when an import's signature is known,
271
+ + and the generic aot_invoke_native sequence - eight dereferences and an argv
272
+ + round trip - when it is not; measured, that is 2 ns against 28 ns per call.
273
+ + Only the name and the signature are read at compile time, never the
274
+ + pointer, so the table is plain text: one "name signature" pair per line,
275
+ + # starts a comment. */
276
+ +static bool
277
+ +register_native_signatures(const char *file_name)
278
+ +{
279
+ + char line[256], name[128], sig[128];
280
+ + NativeSymbol *symbols = NULL, *grown;
281
+ + uint32 count = 0, capacity = 0;
282
+ + FILE *file = fopen(file_name, "r");
283
+ +
284
+ + if (!file) {
285
+ + printf("Failed to open native signature file %s\n", file_name);
286
+ + return false;
287
+ + }
288
+ +
289
+ + while (fgets(line, sizeof(line), file)) {
290
+ + if (line[0] == '#' || sscanf(line, "%127s %127s", name, sig) != 2)
291
+ + continue;
292
+ + if (count == capacity) {
293
+ + capacity = capacity ? capacity * 2 : 128;
294
+ + if (!(grown = realloc(symbols, capacity * sizeof(NativeSymbol))))
295
+ + break;
296
+ + symbols = grown;
297
+ + }
298
+ + symbols[count].symbol = strdup(name);
299
+ + /* never called at compile time, but must not be NULL */
300
+ + symbols[count].func_ptr = (void *)(uintptr_t)1;
301
+ + symbols[count].signature = strdup(sig);
302
+ + symbols[count].attachment = NULL;
303
+ + if (!symbols[count].symbol || !symbols[count].signature)
304
+ + break;
305
+ + count++;
306
+ + }
307
+ + fclose(file);
308
+ +
309
+ + /* The table lives as long as the process; nothing frees it. */
310
+ + if (!wasm_runtime_register_natives("env", symbols, count)) {
311
+ + printf("Failed to register natives from %s: a signature is malformed\n",
312
+ + file_name);
313
+ + return false;
314
+ + }
315
+ + printf("Registered %u native signatures from %s\n", count, file_name);
316
+ + return true;
317
+ +}
318
+ +
319
+ /* clang-format off */
320
+ static void
321
+ print_help()
322
+ @@ -207,6 +257,11 @@ print_help()
323
+ printf(" are shared object (.so) files, for example:\n");
324
+ printf(" --native-lib=test1.so --native-lib=test2.so\n");
325
+ #endif
326
+ + printf(" --native-signatures=<file>\n");
327
+ + printf(" Read the host's native signatures from a text file,\n");
328
+ + printf(" one \"name signature\" pair per line, so that calls to\n");
329
+ + printf(" them are emitted as direct calls, e.g.\n");
330
+ + printf(" get_user_health (i)i\n");
331
+ printf(" --invoke-c-api-import Treat unknown import function as wasm-c-api import function and\n");
332
+ printf(" quick call it from AOT code\n");
333
+ #if WASM_ENABLE_LINUX_PERF != 0
334
+ @@ -401,6 +456,7 @@ main(int argc, char *argv[])
335
+ int log_verbose_level = 2;
336
+ bool sgx_mode = false, size_level_set = false, use_dummy_wasm = false;
337
+ int exit_status = EXIT_FAILURE;
338
+ + const char *native_signature_file = NULL;
339
+ #if BH_HAS_DLFCN
340
+ const char *native_lib_list[8] = { NULL };
341
+ uint32 native_lib_count = 0;
342
+ @@ -638,6 +694,11 @@ main(int argc, char *argv[])
343
+ native_lib_list[native_lib_count++] = argv[0] + 13;
344
+ }
345
+ #endif
346
+ + else if (!strncmp(argv[0], "--native-signatures=", 20)) {
347
+ + if (argv[0][20] == '\0')
348
+ + PRINT_HELP_AND_EXIT();
349
+ + native_signature_file = argv[0] + 20;
350
+ + }
351
+ else if (!strcmp(argv[0], "--invoke-c-api-import")) {
352
+ option.quick_invoke_c_api_import = true;
353
+ }
354
+ @@ -764,6 +825,10 @@ main(int argc, char *argv[])
355
+ return -1;
356
+ }
357
+
358
+ + if (native_signature_file
359
+ + && !register_native_signatures(native_signature_file))
360
+ + goto fail1;
361
+ +
362
+ bh_log_set_verbose_level(log_verbose_level);
363
+
364
+ #if BH_HAS_DLFCN