RISC-V: New emulations to make path searches follow glibc ABI.
authorJim Wilson <jimw@sifive.com>
Tue, 8 May 2018 20:34:03 +0000 (13:34 -0700)
committerJim Wilson <jimw@sifive.com>
Tue, 8 May 2018 20:34:03 +0000 (13:34 -0700)
ld/
PR ld/22962
* Makefile.am (ALL_EMULATION_SOURCES): Add eelf32lriscv_ilp32f.c,
eelf32lriscv_ilp32.c, eelf64lriscv_lp64f.c, eelf64lriscv_lp64.c.
(eelf32lriscv_ilp32f.c, eelf32lriscv_ilp32.c): New build rules.
(eelf64lriscv_lp64f.c, eelf64lriscv_lp64.c): New build rules.
* Makefile.in: Regenerated.
* configure.tgt (riscv32*-*-linux*, riscv64*-*-linux*): New.
* ld/emulparams/elf32lriscv.sh: Set LIBPATH_SUFFIX.
* ld/emulparams/elf32lriscv_ilp32.sh: New.
* ld/emulparams/elf32lriscv_ilp32f.sh: New.
* ld/emulparams/elf64lriscv-defs.sh: Don't set LIBPATH_SUFFIX here.
* ld/emulparams/elf64lriscv.sh: Set LIBPATH_SUFFIX.
* ld/emulparams/elf64lriscv_lp64.sh: New.
* ld/emulparams/elf64lriscv_lp64f.sh: New.
* ld/genscripts.sh (append_to_lib_path): Change LIBPATH_SUFFIX test to
a for.  Inside loop, change LIBPATH_SUFFIX uses to libpath_suffix.
(LIB_PATH): In LIB_PATH if, add loop for LIBPATH_SUFFIX, changes uses
inside loop to libpath_suffix.

12 files changed:
ld/ChangeLog
ld/Makefile.am
ld/Makefile.in
ld/configure.tgt
ld/emulparams/elf32lriscv.sh
ld/emulparams/elf32lriscv_ilp32.sh [new file with mode: 0644]
ld/emulparams/elf32lriscv_ilp32f.sh [new file with mode: 0644]
ld/emulparams/elf64lriscv-defs.sh
ld/emulparams/elf64lriscv.sh
ld/emulparams/elf64lriscv_lp64.sh [new file with mode: 0644]
ld/emulparams/elf64lriscv_lp64f.sh [new file with mode: 0644]
ld/genscripts.sh

index 7c753d84233fe8733945d8be643e2552abfed49e..2f9e01d2f818660736072b995b444a3ceda83926 100644 (file)
@@ -1,3 +1,24 @@
+2018-05-08  Jim Wilson  <jimw@sifive.com>
+
+       PR ld/22962
+       * Makefile.am (ALL_EMULATION_SOURCES): Add eelf32lriscv_ilp32f.c,
+       eelf32lriscv_ilp32.c, eelf64lriscv_lp64f.c, eelf64lriscv_lp64.c.
+       (eelf32lriscv_ilp32f.c, eelf32lriscv_ilp32.c): New build rules.
+       (eelf64lriscv_lp64f.c, eelf64lriscv_lp64.c): New build rules.
+       * Makefile.in: Regenerated.
+       * configure.tgt (riscv32*-*-linux*, riscv64*-*-linux*): New.
+       * ld/emulparams/elf32lriscv.sh: Set LIBPATH_SUFFIX.
+       * ld/emulparams/elf32lriscv_ilp32.sh: New.
+       * ld/emulparams/elf32lriscv_ilp32f.sh: New.
+       * ld/emulparams/elf64lriscv-defs.sh: Don't set LIBPATH_SUFFIX here.
+       * ld/emulparams/elf64lriscv.sh: Set LIBPATH_SUFFIX.
+       * ld/emulparams/elf64lriscv_lp64.sh: New.
+       * ld/emulparams/elf64lriscv_lp64f.sh: New.
+       * ld/genscripts.sh (append_to_lib_path): Change LIBPATH_SUFFIX test to
+       a for.  Inside loop, change LIBPATH_SUFFIX uses to libpath_suffix.
+       (LIB_PATH): In LIB_PATH if, add loop for LIBPATH_SUFFIX, changes uses
+       inside loop to libpath_suffix.
+
 2018-05-03  Jim Wilson  <jimw@sifive.com>
 
        * Makefile.am (earmelfb_linux_fdpiceabi.c): Fix typo in dependencies.
index 2d758b1ee32b356f03e5ae17a36ce30f62cd1510..8e4c8774d1bc533de0761e98d65e3271f131b19d 100644 (file)
@@ -266,6 +266,8 @@ ALL_EMULATION_SOURCES = \
        eelf32ppcvxworks.c \
        eelf32ppcwindiss.c \
        eelf32lriscv.c \
+       eelf32lriscv_ilp32f.c \
+       eelf32lriscv_ilp32.c \
        eelf32rl78.c \
        eelf32rx.c \
        eelf32tilegx.c \
@@ -434,6 +436,8 @@ ALL_64_EMULATION_SOURCES = \
        eelf64hppa.c \
        eelf64lppc.c \
        eelf64lriscv.c \
+       eelf64lriscv_lp64f.c \
+       eelf64lriscv_lp64.c \
        eelf64ltsmip.c \
        eelf64ltsmip_fbsd.c \
        eelf64mmix.c \
@@ -1103,6 +1107,16 @@ eelf32lriscv.c: $(srcdir)/emulparams/elf32lriscv.sh \
   $(srcdir)/emultempl/riscvelf.em $(srcdir)/scripttempl/elf.sc \
   ${GEN_DEPENDS}
 
+eelf32lriscv_ilp32f.c: $(srcdir)/emulparams/elf32lriscv_ilp32f.sh \
+  $(srcdir)/emulparams/elf32lriscv-defs.sh $(ELF_DEPS) \
+  $(srcdir)/emultempl/riscvelf.em $(srcdir)/scripttempl/elf.sc \
+  ${GEN_DEPENDS}
+
+eelf32lriscv_ilp32.c: $(srcdir)/emulparams/elf32lriscv_ilp32.sh \
+  $(srcdir)/emulparams/elf32lriscv-defs.sh $(ELF_DEPS) \
+  $(srcdir)/emultempl/riscvelf.em $(srcdir)/scripttempl/elf.sc \
+  ${GEN_DEPENDS}
+
 eelf32lsmip.c: $(srcdir)/emulparams/elf32lsmip.sh \
   $(srcdir)/emulparams/elf32lmip.sh $(srcdir)/emulparams/elf32bmip.sh \
   $(ELF_DEPS) $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc \
@@ -1748,6 +1762,18 @@ eelf64lriscv.c: $(srcdir)/emulparams/elf64lriscv.sh \
   $(srcdir)/emultempl/riscvelf.em $(srcdir)/scripttempl/elf.sc \
   ${GEN_DEPENDS}
 
+eelf64lriscv_lp64f.c: $(srcdir)/emulparams/elf64lriscv_lp64f.sh \
+  $(srcdir)/emulparams/elf64lriscv-defs.sh \
+  $(srcdir)/emulparams/elf32lriscv-defs.sh $(ELF_DEPS) \
+  $(srcdir)/emultempl/riscvelf.em $(srcdir)/scripttempl/elf.sc \
+  ${GEN_DEPENDS}
+
+eelf64lriscv_lp64.c: $(srcdir)/emulparams/elf64lriscv_lp64.sh \
+  $(srcdir)/emulparams/elf64lriscv-defs.sh \
+  $(srcdir)/emulparams/elf32lriscv-defs.sh $(ELF_DEPS) \
+  $(srcdir)/emultempl/riscvelf.em $(srcdir)/scripttempl/elf.sc \
+  ${GEN_DEPENDS}
+
 eelf64ltsmip.c: $(srcdir)/emulparams/elf64ltsmip.sh \
   $(srcdir)/emulparams/elf64btsmip.sh $(srcdir)/emulparams/elf64bmip-defs.sh \
   $(srcdir)/emulparams/elf32bmipn32-defs.sh $(ELF_DEPS) \
index 8e0122c8556a660e31f5df41737f001474852a3d..afd2a4bb8815b138e2b2010beaa13eec02569d9a 100644 (file)
@@ -635,6 +635,8 @@ ALL_EMULATION_SOURCES = \
        eelf32ppcvxworks.c \
        eelf32ppcwindiss.c \
        eelf32lriscv.c \
+       eelf32lriscv_ilp32f.c \
+       eelf32lriscv_ilp32.c \
        eelf32rl78.c \
        eelf32rx.c \
        eelf32tilegx.c \
@@ -802,6 +804,8 @@ ALL_64_EMULATION_SOURCES = \
        eelf64hppa.c \
        eelf64lppc.c \
        eelf64lriscv.c \
+       eelf64lriscv_lp64f.c \
+       eelf64lriscv_lp64.c \
        eelf64ltsmip.c \
        eelf64ltsmip_fbsd.c \
        eelf64mmix.c \
@@ -1180,6 +1184,8 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lr5900.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lr5900n32.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lriscv.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lriscv_ilp32.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lriscv_ilp32f.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lsmip.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32ltsmip.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32ltsmip_fbsd.Po@am__quote@
@@ -1234,6 +1240,8 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64hppa.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lppc.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lriscv.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lriscv_lp64.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lriscv_lp64f.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64ltsmip.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64ltsmip_fbsd.Po@am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64mmix.Po@am__quote@
@@ -2604,6 +2612,16 @@ eelf32lriscv.c: $(srcdir)/emulparams/elf32lriscv.sh \
   $(srcdir)/emultempl/riscvelf.em $(srcdir)/scripttempl/elf.sc \
   ${GEN_DEPENDS}
 
+eelf32lriscv_ilp32f.c: $(srcdir)/emulparams/elf32lriscv_ilp32f.sh \
+  $(srcdir)/emulparams/elf32lriscv-defs.sh $(ELF_DEPS) \
+  $(srcdir)/emultempl/riscvelf.em $(srcdir)/scripttempl/elf.sc \
+  ${GEN_DEPENDS}
+
+eelf32lriscv_ilp32.c: $(srcdir)/emulparams/elf32lriscv_ilp32.sh \
+  $(srcdir)/emulparams/elf32lriscv-defs.sh $(ELF_DEPS) \
+  $(srcdir)/emultempl/riscvelf.em $(srcdir)/scripttempl/elf.sc \
+  ${GEN_DEPENDS}
+
 eelf32lsmip.c: $(srcdir)/emulparams/elf32lsmip.sh \
   $(srcdir)/emulparams/elf32lmip.sh $(srcdir)/emulparams/elf32bmip.sh \
   $(ELF_DEPS) $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc \
@@ -3249,6 +3267,18 @@ eelf64lriscv.c: $(srcdir)/emulparams/elf64lriscv.sh \
   $(srcdir)/emultempl/riscvelf.em $(srcdir)/scripttempl/elf.sc \
   ${GEN_DEPENDS}
 
+eelf64lriscv_lp64f.c: $(srcdir)/emulparams/elf64lriscv_lp64f.sh \
+  $(srcdir)/emulparams/elf64lriscv-defs.sh \
+  $(srcdir)/emulparams/elf32lriscv-defs.sh $(ELF_DEPS) \
+  $(srcdir)/emultempl/riscvelf.em $(srcdir)/scripttempl/elf.sc \
+  ${GEN_DEPENDS}
+
+eelf64lriscv_lp64.c: $(srcdir)/emulparams/elf64lriscv_lp64.sh \
+  $(srcdir)/emulparams/elf64lriscv-defs.sh \
+  $(srcdir)/emulparams/elf32lriscv-defs.sh $(ELF_DEPS) \
+  $(srcdir)/emultempl/riscvelf.em $(srcdir)/scripttempl/elf.sc \
+  ${GEN_DEPENDS}
+
 eelf64ltsmip.c: $(srcdir)/emulparams/elf64ltsmip.sh \
   $(srcdir)/emulparams/elf64btsmip.sh $(srcdir)/emulparams/elf64bmip-defs.sh \
   $(srcdir)/emulparams/elf32bmipn32-defs.sh $(ELF_DEPS) \
index 1999010896f189215cb240a0c52e4c33d597adb0..4c4ab850f2244aa55517fe5b0f44486e70a092ec 100644 (file)
@@ -627,9 +627,15 @@ powerpc-*-beos*)   targ_emul=aixppc ;;
 powerpc-*-windiss*)    targ_emul=elf32ppcwindiss ;;
 powerpc-*-lynxos*)     targ_emul=ppclynx ;;
 pru*-*-*)              targ_emul=pruelf ;;
+riscv32*-*-linux*)     targ_emul=elf32lriscv
+                       targ_extra_emuls="elf32lriscv_ilp32f elf32lriscv_ilp32 elf64lriscv elf64lriscv_lp64f elf64lriscv_lp64"
+                       targ_extra_libpath=$targ_extra_emuls ;;
 riscv32*-*-*)          targ_emul=elf32lriscv
                        targ_extra_emuls="elf64lriscv"
                        targ_extra_libpath=$targ_extra_emuls ;;
+riscv64*-*-linux*)     targ_emul=elf64lriscv
+                       targ_extra_emuls="elf64lriscv_lp64f elf64lriscv_lp64 elf32lriscv elf32lriscv_ilp32f elf32lriscv_ilp32"
+                       targ_extra_libpath=$targ_extra_emuls ;;
 riscv64*-*-*)          targ_emul=elf64lriscv
                        targ_extra_emuls="elf32lriscv"
                        targ_extra_libpath=$targ_extra_emuls ;;
index aac08e78f1c0e49be141d55546ad1bffbb057c3e..e91f884cec446b79e65a250773eb7cd59a14dd4e 100644 (file)
@@ -1,2 +1,15 @@
+# RV32 code using ILP32D ABI.
+# ABI not in emulation name to avoid breaking backward compatibility.
 . ${srcdir}/emulparams/elf32lriscv-defs.sh
 OUTPUT_FORMAT="elf32-littleriscv"
+
+# On Linux, first look for 32 bit ILP32D target libraries in /lib/ilp32d as per
+# the glibc ABI.
+case "$target" in
+  riscv32*-linux*)
+    case "$EMULATION_NAME" in
+      *32*)
+       LIBPATH_SUFFIX="/ilp32d" ;;
+    esac
+    ;;
+esac
diff --git a/ld/emulparams/elf32lriscv_ilp32.sh b/ld/emulparams/elf32lriscv_ilp32.sh
new file mode 100644 (file)
index 0000000..ec676bc
--- /dev/null
@@ -0,0 +1,14 @@
+# RV32 code using ILP32 ABI.
+. ${srcdir}/emulparams/elf32lriscv-defs.sh
+OUTPUT_FORMAT="elf32-littleriscv"
+
+# On Linux, first look for 32 bit ILP32 target libraries in /lib/ilp32 as per
+# the glibc ABI.
+case "$target" in
+  riscv32*-linux*)
+    case "$EMULATION_NAME" in
+      *32*)
+       LIBPATH_SUFFIX="/ilp32" ;;
+    esac
+    ;;
+esac
diff --git a/ld/emulparams/elf32lriscv_ilp32f.sh b/ld/emulparams/elf32lriscv_ilp32f.sh
new file mode 100644 (file)
index 0000000..63304f9
--- /dev/null
@@ -0,0 +1,14 @@
+# RV32 code using ILP32F ABI.
+. ${srcdir}/emulparams/elf32lriscv-defs.sh
+OUTPUT_FORMAT="elf32-littleriscv"
+
+# On Linux, first look for 32 bit ILP32F target libraries in /lib/ilp32f as per
+# the glibc ABI.
+case "$target" in
+  riscv32*-linux*)
+    case "$EMULATION_NAME" in
+      *32*)
+       LIBPATH_SUFFIX="/ilp32f" ;;
+    esac
+    ;;
+esac
index 63087142079f75fb58cf8d48465262b2e9c4b054..930f333979e325ff1909875841e9010575eb7621 100644 (file)
@@ -1,13 +1,2 @@
 . ${srcdir}/emulparams/elf32lriscv-defs.sh
 ELFSIZE=64
-
-# Look for 64 bit target libraries in /lib64, /usr/lib64 etc., first
-# on Linux.
-case "$target" in
-  riscv64*-linux*)
-    case "$EMULATION_NAME" in
-      *64*)
-       LIBPATH_SUFFIX=64 ;;
-    esac
-    ;;
-esac
index 3a6a652c9d844837ceec9feee8c7d86f7377c110..f0a10abec7e2a93b7fbedd0d5e0d91012a7bd5b8 100644 (file)
@@ -1,2 +1,15 @@
+# RV64 code using LP64D ABI.
+# ABI not in emulation name to avoid breaking backward compatibility.
 . ${srcdir}/emulparams/elf64lriscv-defs.sh
 OUTPUT_FORMAT="elf64-littleriscv"
+
+# On Linux, first look for 64 bit LP64D target libraries in /lib64/lp64d as per
+# the glibc ABI, and then /lib64 for backward compatility.
+case "$target" in
+  riscv64*-linux*)
+    case "$EMULATION_NAME" in
+      *64*)
+       LIBPATH_SUFFIX="64/lp64d 64";;
+    esac
+    ;;
+esac
diff --git a/ld/emulparams/elf64lriscv_lp64.sh b/ld/emulparams/elf64lriscv_lp64.sh
new file mode 100644 (file)
index 0000000..80a8f82
--- /dev/null
@@ -0,0 +1,14 @@
+# RV64 code using LP64 ABI.
+. ${srcdir}/emulparams/elf64lriscv-defs.sh
+OUTPUT_FORMAT="elf64-littleriscv"
+
+# On Linux, first look for 64 bit LP64 target libraries in /lib64/lp64 as per
+# the glibc ABI, and then /lib64 for backward compatility.
+case "$target" in
+  riscv64*-linux*)
+    case "$EMULATION_NAME" in
+      *64*)
+       LIBPATH_SUFFIX="64/lp64 64";;
+    esac
+    ;;
+esac
diff --git a/ld/emulparams/elf64lriscv_lp64f.sh b/ld/emulparams/elf64lriscv_lp64f.sh
new file mode 100644 (file)
index 0000000..8f86421
--- /dev/null
@@ -0,0 +1,14 @@
+# RV64 code using LP64F ABI.
+. ${srcdir}/emulparams/elf64lriscv-defs.sh
+OUTPUT_FORMAT="elf64-littleriscv"
+
+# On Linux, first look for 64 bit LP64F target libraries in /lib64/lp64f as per
+# the glibc ABI, and then /lib64 for backward compatility.
+case "$target" in
+  riscv64*-linux*)
+    case "$EMULATION_NAME" in
+      *64*)
+       LIBPATH_SUFFIX="64/lp64f 64";;
+    esac
+    ;;
+esac
index 8732422b3a147c1819a69ee9eeba8d888cb5b1cb..370b22269db2ee9962153bcd19ef1edcf8724127 100755 (executable)
@@ -155,9 +155,9 @@ append_to_lib_path()
        lib="=${lib}"
       fi
       skip_lib=no
-      if test -n "${LIBPATH_SUFFIX}"; then
+      for libpath_suffix in ${LIBPATH_SUFFIX}; do
        case "${lib}" in
-         *${LIBPATH_SUFFIX})
+         *${libpath_suffix})
            case :${lib_path1}: in
              *:${lib}:*) ;;
              ::) lib_path1=${lib} ;;
@@ -171,13 +171,13 @@ append_to_lib_path()
            fi
            if test "${skip_lib}" = "no"; then
              case :${lib_path1}: in
-               *:${lib}${LIBPATH_SUFFIX}:*) ;;
-               ::) lib_path1=${lib}${LIBPATH_SUFFIX} ;;
-               *) lib_path1=${lib_path1}:${lib}${LIBPATH_SUFFIX} ;;
+               *:${lib}${libpath_suffix}:*) ;;
+               ::) lib_path1=${lib}${libpath_suffix} ;;
+               *) lib_path1=${lib_path1}:${lib}${libpath_suffix} ;;
              esac
            fi ;;
        esac
-      fi
+      done
       if test "${skip_lib}" = "no"; then
        case :${lib_path1}:${lib_path2}: in
          *:${lib}:*) ;;
@@ -203,10 +203,12 @@ if [ "${LIB_PATH}" != ":" ] ; then
     # because 64bit libraries may be in both places, depending on
     # cross-development setup method (e.g.: /usr/s390x-linux/lib64
     # vs. /usr/s390-linux/lib64)
-    case "${NATIVE}:${LIBPATH_SUFFIX}:${TOOL_LIB}" in
-      :* | *::* | *:*:*${LIBPATH_SUFFIX}) ;;
-      *) libs="${exec_prefix}/${target_alias}/lib${LIBPATH_SUFFIX}" ;;
-    esac
+    for libpath_suffix in ${LIBPATH_SUFFIX}; do
+      case "${NATIVE}:${libpath_suffix}:${TOOL_LIB}" in
+       :* | *::* | *:*:*${libpath_suffix}) ;;
+       *) libs="${exec_prefix}/${target_alias}/lib${libpath_suffix}" ;;
+      esac
+    done
     libs="${exec_prefix}/${TOOL_LIB}/lib ${libs}"
   fi
   append_to_lib_path ${libs}