aot_validator.c 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. /*
  2. * Copyright (C) 2025 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #include "aot_validator.h"
  6. static void
  7. set_error_buf(char *error_buf, uint32 error_buf_size, const char *string)
  8. {
  9. if (error_buf != NULL) {
  10. snprintf(error_buf, error_buf_size,
  11. "AOT module load failed: from validator. %s", string);
  12. }
  13. }
  14. static bool
  15. aot_memory_info_validate(const AOTModule *module, char *error_buf,
  16. uint32 error_buf_size)
  17. {
  18. if (module->import_memory_count > 0) {
  19. set_error_buf(error_buf, error_buf_size,
  20. "import memory is not supported");
  21. return false;
  22. }
  23. if (module->memory_count < 1) {
  24. set_error_buf(error_buf, error_buf_size,
  25. "there should be >=1 memory in one aot module");
  26. return false;
  27. }
  28. return true;
  29. }
  30. bool
  31. aot_module_validate(const AOTModule *module, char *error_buf,
  32. uint32 error_buf_size)
  33. {
  34. if (!aot_memory_info_validate(module, error_buf, error_buf_size)) {
  35. return false;
  36. }
  37. return true;
  38. }