aot_reloc_mips.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (C) 2019 Intel Corporation. All rights reserved.
  3. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. */
  5. #include "aot_reloc.h"
  6. #define R_MIPS_32 2 /* Direct 32 bit */
  7. #define R_MIPS_26 4 /* Direct 26 bit shifted */
  8. /* clang-format off */
  9. static SymbolMap target_sym_map[] = {
  10. REG_COMMON_SYMBOLS
  11. };
  12. /* clang-format on */
  13. SymbolMap *
  14. get_target_symbol_map(uint32 *sym_num)
  15. {
  16. *sym_num = sizeof(target_sym_map) / sizeof(SymbolMap);
  17. return target_sym_map;
  18. }
  19. void
  20. get_current_target(char *target_buf, uint32 target_buf_size)
  21. {
  22. snprintf(target_buf, target_buf_size, "mips");
  23. }
  24. static uint32
  25. get_plt_item_size(void)
  26. {
  27. return 0;
  28. }
  29. void
  30. init_plt_table(uint8 *plt)
  31. {
  32. (void)plt;
  33. }
  34. uint32
  35. get_plt_table_size()
  36. {
  37. return get_plt_item_size() * (sizeof(target_sym_map) / sizeof(SymbolMap));
  38. }
  39. bool
  40. apply_relocation(AOTModule *module, uint8 *target_section_addr,
  41. uint32 target_section_size, uint64 reloc_offset,
  42. int64 reloc_addend, uint32 reloc_type, void *symbol_addr,
  43. int32 symbol_index, char *error_buf, uint32 error_buf_size)
  44. {
  45. switch (reloc_type) {
  46. /* TODO: implement relocation for mips */
  47. case R_MIPS_26:
  48. case R_MIPS_32:
  49. default:
  50. if (error_buf != NULL)
  51. snprintf(error_buf, error_buf_size,
  52. "Load relocation section failed: "
  53. "invalid relocation type %d.",
  54. reloc_type);
  55. return false;
  56. }
  57. return true;
  58. }