]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
RISC-V: Add path of library directories for the 32-bit
authorZong Li <zongbox@gmail.com>
Fri, 30 Nov 2018 09:15:44 +0000 (17:15 +0800)
committerAlistair Francis <alistair.francis@wdc.com>
Thu, 16 Jan 2020 22:10:36 +0000 (14:10 -0800)
For the recommand of 64 bit version, we add the libraries path of 32 bit
in this patch.

The status of RV32 binaries under RV64 kernels is that the ISA
optionally supports having different XLEN for user and supervisor modes,
but AFAIK there's no silicon that implements this feature, and the Linux
kernel doesn't support it yet.

For the recommand of 64 bit version, we add the libraries path of 32 bit
in this patch. This includes a fix to avoid an out of bound array check
when building with GCC 8.2.

sysdeps/unix/sysv/linux/riscv/dl-cache.h

index c297dfe84fcf35a18a67a4481b8796e53848f66c..60fc172edbf2092cd001e780d59207668643e288 100644 (file)
@@ -34,6 +34,8 @@
    RISC-V, libraries can be found in paths ending in:
      - /lib64/lp64d
      - /lib64/lp64
+     - /lib32/ilp32d
+     - /lib32/ilp32
      - /lib (only ld.so)
    so this will add all of those paths.
 
   do                                                                   \
     {                                                                  \
       size_t len = strlen (dir);                                       \
-      char path[len + 9];                                              \
+      char path[len + 10];                                             \
       memcpy (path, dir, len + 1);                                     \
-      if (len >= 12 && ! memcmp(path + len - 12, "/lib64/lp64d", 12))  \
+      if (len >= 13 && ! memcmp(path + len - 13, "/lib32/ilp32d", 13)) \
+        {                                                              \
+          len -= 9;                                                    \
+         path[len] = '\0';                                             \
+        }                                                              \
+      if (len >= 12                                                    \
+          && (! memcmp(path + len - 12, "/lib32/ilp32", 12)            \
+              || ! memcmp(path + len - 12, "/lib64/lp64d", 12)))       \
        {                                                               \
          len -= 8;                                                     \
          path[len] = '\0';                                             \
       add_dir (path);                                                  \
       if (len >= 4 && ! memcmp(path + len - 4, "/lib", 4))             \
        {                                                               \
+         memcpy (path + len, "32/ilp32d", 10);                         \
+         add_dir (path);                                               \
+         memcpy (path + len, "32/ilp32", 9);                           \
+         add_dir (path);                                               \
          memcpy (path + len, "64/lp64d", 9);                           \
          add_dir (path);                                               \
          memcpy (path + len, "64/lp64", 8);                            \