0007-riscv32.patch 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. diff -Nur elf2flt-v2021.08.orig/elf2flt.c elf2flt-v2021.08/elf2flt.c
  2. --- elf2flt-v2021.08.orig/elf2flt.c 2023-01-09 11:08:28.637676113 +0100
  3. +++ elf2flt-v2021.08/elf2flt.c 2023-01-09 11:16:05.447182514 +0100
  4. @@ -81,7 +81,7 @@
  5. #include <elf/v850.h>
  6. #elif defined(TARGET_xtensa)
  7. #include <elf/xtensa.h>
  8. -#elif defined(TARGET_riscv64)
  9. +#elif defined(TARGET_riscv64) || defined(TARGET_riscv32)
  10. #include <elf/riscv.h>
  11. #endif
  12. @@ -127,6 +127,8 @@
  13. #define ARCH "xtensa"
  14. #elif defined(TARGET_riscv64)
  15. #define ARCH "riscv64"
  16. +#elif defined(TARGET_riscv32)
  17. +#define ARCH "riscv32"
  18. #else
  19. #error "Don't know how to support your CPU architecture??"
  20. #endif
  21. @@ -351,7 +353,8 @@
  22. {
  23. if ((s->flags & (SEC_DATA | SEC_READONLY | SEC_RELOC)) ==
  24. (SEC_DATA | SEC_READONLY | SEC_RELOC)) {
  25. -#if defined(TARGET_m68k) || defined(TARGET_riscv64) || defined(TARGET_xtensa)
  26. +#if defined(TARGET_m68k) || defined(TARGET_riscv64) || \
  27. + defined(TARGET_xtensa) || defined(TARGET_riscv32)
  28. if (!strcmp(".eh_frame", s->name))
  29. return false;
  30. #endif
  31. @@ -838,12 +841,21 @@
  32. goto good_32bit_resolved_reloc;
  33. default:
  34. goto bad_resolved_reloc;
  35. -#elif defined(TARGET_riscv64)
  36. +#elif defined(TARGET_riscv64) || defined(TARGET_riscv32)
  37. case R_RISCV_32_PCREL:
  38. + case R_RISCV_ADD8:
  39. + case R_RISCV_ADD16:
  40. case R_RISCV_ADD32:
  41. case R_RISCV_ADD64:
  42. + case R_RISCV_SUB6:
  43. + case R_RISCV_SUB8:
  44. + case R_RISCV_SUB16:
  45. case R_RISCV_SUB32:
  46. case R_RISCV_SUB64:
  47. + case R_RISCV_SET6:
  48. + case R_RISCV_SET8:
  49. + case R_RISCV_SET16:
  50. + case R_RISCV_SET32:
  51. continue;
  52. case R_RISCV_32:
  53. case R_RISCV_64:
  54. diff -Nur elf2flt-v2021.08.orig/ld-elf2flt.c elf2flt-v2021.08/ld-elf2flt.c
  55. --- elf2flt-v2021.08.orig/ld-elf2flt.c 2023-01-09 11:08:16.441289072 +0100
  56. +++ elf2flt-v2021.08/ld-elf2flt.c 2023-01-09 11:16:43.236237537 +0100
  57. @@ -327,7 +327,7 @@
  58. /* riscv adds a global pointer symbol to the linker file with the
  59. "RISCV_GP:" prefix. Remove the prefix for riscv64 architecture and
  60. the entire line for other architectures. */
  61. - if (streq(TARGET_CPU, "riscv64"))
  62. + if (streq(TARGET_CPU, "riscv64") || streq(TARGET_CPU, "riscv32"))
  63. append_sed(&sed, "^RISCV_GP:", "");
  64. else
  65. append_sed(&sed, "^RISCV_GP:", NULL);