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