0001-elf2flt-add-RISC-V-32-bit-support.patch 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. From 44e34cb50f2d25848a85a59adbc561eee66278e8 Mon Sep 17 00:00:00 2001
  2. From: Yimin Gu <ustcymgu@gmail.com>
  3. Date: Wed, 14 Dec 2022 06:49:46 -0500
  4. Subject: [PATCH] elf2flt: add RISC-V 32-bit support
  5. Allow elf2flt to work with RISC-V 32-bit targets. With these changes, the
  6. uclibc toolchain and busybox can work fine for rv32 no MMU systems with
  7. no noticable problem.
  8. Signed-off-by: Charles Lohr <lohr85@gmail.com>
  9. [Rebased onto latest tree for upstreaming]
  10. Signed-off-by: Jesse Taube <Mr.Bossman075@gmail.com>
  11. [Add more ELF relco types and edit commit message]
  12. Signed-off-by: Yimin Gu <ustcymgu@gmail.com>
  13. ---
  14. elf2flt.c | 6 ++++--
  15. ld-elf2flt.c | 2 +-
  16. 2 files changed, 5 insertions(+), 3 deletions(-)
  17. diff --git a/elf2flt.c b/elf2flt.c
  18. index f37cfa2..04b6b43 100644
  19. --- a/elf2flt.c
  20. +++ b/elf2flt.c
  21. @@ -81,7 +81,7 @@ const char *elf2flt_progname;
  22. #include <elf/v850.h>
  23. #elif defined(TARGET_xtensa)
  24. #include <elf/xtensa.h>
  25. -#elif defined(TARGET_riscv64)
  26. +#elif defined(TARGET_riscv64) || defined(TARGET_riscv32)
  27. #include <elf/riscv.h>
  28. #endif
  29. @@ -127,6 +127,8 @@ const char *elf2flt_progname;
  30. #define ARCH "xtensa"
  31. #elif defined(TARGET_riscv64)
  32. #define ARCH "riscv64"
  33. +#elif defined(TARGET_riscv32)
  34. +#define ARCH "riscv32"
  35. #else
  36. #error "Don't know how to support your CPU architecture??"
  37. #endif
  38. @@ -822,7 +824,7 @@ output_relocs (
  39. goto good_32bit_resolved_reloc_update_text;
  40. default:
  41. goto bad_resolved_reloc;
  42. -#elif defined(TARGET_riscv64)
  43. +#elif defined(TARGET_riscv64) || defined(TARGET_riscv32)
  44. case R_RISCV_NONE:
  45. case R_RISCV_32_PCREL:
  46. case R_RISCV_ADD8:
  47. diff --git a/ld-elf2flt.c b/ld-elf2flt.c
  48. index 75ee1bb..68b2a4a 100644
  49. --- a/ld-elf2flt.c
  50. +++ b/ld-elf2flt.c
  51. @@ -327,7 +327,7 @@ static int do_final_link(void)
  52. /* riscv adds a global pointer symbol to the linker file with the
  53. "RISCV_GP:" prefix. Remove the prefix for riscv64 architecture and
  54. the entire line for other architectures. */
  55. - if (streq(TARGET_CPU, "riscv64"))
  56. + if (streq(TARGET_CPU, "riscv64") || streq(TARGET_CPU, "riscv32"))
  57. append_sed(&sed, "^RISCV_GP:", "");
  58. else
  59. append_sed(&sed, "^RISCV_GP:", NULL);
  60. --
  61. 2.30.2