add-riscv-support.patch 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. From fd50228cc213d2d87f5e3cf1f123acb3fda9b04e Mon Sep 17 00:00:00 2001
  2. From: Christoph Muellner <cmuellner@linux.com>
  3. Date: Mon, 28 Jun 2021 00:34:12 +0200
  4. Subject: [PATCH] ldconfig: Add RISC-V support
  5. ldconfig-native does not support RISC-V at the moment.
  6. Let's pull the reqired constants from upstream and add
  7. the required parsing code.
  8. Upstream-Status: Backport
  9. Signed-off-by: Christoph Muellner <cmuellner@linux.com>
  10. ---
  11. cache.c | 6 ++++++
  12. ldconfig.h | 2 ++
  13. readelflib.c | 10 ++++++++++
  14. 3 files changed, 18 insertions(+)
  15. diff --git a/cache.c b/cache.c
  16. index c4f5411..a3b9e70 100644
  17. --- a/cache.c
  18. +++ b/cache.c
  19. @@ -125,6 +125,12 @@ print_entry (const char *lib, int flag, unsigned int osversion,
  20. case FLAG_AARCH64_LIB64:
  21. fputs (",AArch64", stdout);
  22. break;
  23. + case FLAG_RISCV_FLOAT_ABI_SOFT:
  24. + fputs (",soft-float", stdout);
  25. + break;
  26. + case FLAG_RISCV_FLOAT_ABI_DOUBLE:
  27. + fputs (",double-float", stdout);
  28. + break;
  29. case 0:
  30. break;
  31. default:
  32. diff --git a/ldconfig.h b/ldconfig.h
  33. index 6a8a750..2e5e379 100644
  34. --- a/ldconfig.h
  35. +++ b/ldconfig.h
  36. @@ -38,6 +38,8 @@
  37. #define FLAG_ARM_LIBHF 0x0900
  38. #define FLAG_AARCH64_LIB64 0x0a00
  39. #define FLAG_ARM_LIBSF 0x0b00
  40. +#define FLAG_RISCV_FLOAT_ABI_SOFT 0x0f00
  41. +#define FLAG_RISCV_FLOAT_ABI_DOUBLE 0x1000
  42. /* Name of auxiliary cache. */
  43. #define _PATH_LDCONFIG_AUX_CACHE "/var/cache/ldconfig/aux-cache"
  44. diff --git a/readelflib.c b/readelflib.c
  45. index 9ec0a54..a01e1ce 100644
  46. --- a/readelflib.c
  47. +++ b/readelflib.c
  48. @@ -33,6 +33,10 @@
  49. #define EM_AARCH64 183 /* ARM AARCH64 */
  50. #endif
  51. +#ifndef EM_RISCV
  52. +#define EM_RISCV 243 /* RISC-V */
  53. +#endif
  54. +
  55. #undef check_ptr
  56. #define check_ptr(ptr) \
  57. do \
  58. @@ -331,6 +335,12 @@ process_elf_file64 (const char *file_name, const char *lib, int *flag,
  59. /* see sysdeps/unix/sysv/linux/arm/readelflib.c */
  60. *flag |= FLAG_AARCH64_LIB64|FLAG_ELF_LIBC6;
  61. break;
  62. + case EM_RISCV:
  63. + /* RISC-V libraries are always libc.so.6+. */
  64. + /* NOTE: This does not correctly handle soft-float binaries */
  65. + /* see sysdeps/unix/sysv/linux/riscv/readelflib.c */
  66. + *flag |= FLAG_RISCV_FLOAT_ABI_DOUBLE|FLAG_ELF_LIBC6;
  67. + break;
  68. default:
  69. error(0, 0, "%s is a 64-bit ELF for unknown machine %lx\n",
  70. file_name, (long)elf_header->e_machine);
  71. --
  72. 2.25.1