diff options
author | Jim Wilson <jimw@sifive.com> | 2018-05-08 13:34:03 -0700 |
---|---|---|
committer | Jim Wilson <jimw@sifive.com> | 2018-05-08 13:34:03 -0700 |
commit | 10d980882987d8cd9b2e34651faceff29176148b (patch) | |
tree | 8bf35a82aead8d16f6f5dee55c44721c5e266557 /ld | |
parent | 8ee22052f690c007556b97eed59f49350ece5ca9 (diff) | |
download | gdb-10d980882987d8cd9b2e34651faceff29176148b.zip gdb-10d980882987d8cd9b2e34651faceff29176148b.tar.gz gdb-10d980882987d8cd9b2e34651faceff29176148b.tar.bz2 |
RISC-V: New emulations to make path searches follow glibc ABI.
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.
Diffstat (limited to 'ld')
-rw-r--r-- | ld/ChangeLog | 21 | ||||
-rw-r--r-- | ld/Makefile.am | 26 | ||||
-rw-r--r-- | ld/Makefile.in | 30 | ||||
-rw-r--r-- | ld/configure.tgt | 6 | ||||
-rw-r--r-- | ld/emulparams/elf32lriscv.sh | 13 | ||||
-rw-r--r-- | ld/emulparams/elf32lriscv_ilp32.sh | 14 | ||||
-rw-r--r-- | ld/emulparams/elf32lriscv_ilp32f.sh | 14 | ||||
-rw-r--r-- | ld/emulparams/elf64lriscv-defs.sh | 11 | ||||
-rw-r--r-- | ld/emulparams/elf64lriscv.sh | 13 | ||||
-rw-r--r-- | ld/emulparams/elf64lriscv_lp64.sh | 14 | ||||
-rw-r--r-- | ld/emulparams/elf64lriscv_lp64f.sh | 14 | ||||
-rwxr-xr-x | ld/genscripts.sh | 22 |
12 files changed, 177 insertions, 21 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog index 7c753d8..2f9e01d 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -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. diff --git a/ld/Makefile.am b/ld/Makefile.am index 2d758b1..8e4c877 100644 --- a/ld/Makefile.am +++ b/ld/Makefile.am @@ -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) \ diff --git a/ld/Makefile.in b/ld/Makefile.in index 8e0122c..afd2a4b 100644 --- a/ld/Makefile.in +++ b/ld/Makefile.in @@ -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) \ diff --git a/ld/configure.tgt b/ld/configure.tgt index 1999010..4c4ab85 100644 --- a/ld/configure.tgt +++ b/ld/configure.tgt @@ -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 ;; diff --git a/ld/emulparams/elf32lriscv.sh b/ld/emulparams/elf32lriscv.sh index aac08e7..e91f884 100644 --- a/ld/emulparams/elf32lriscv.sh +++ b/ld/emulparams/elf32lriscv.sh @@ -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 index 0000000..ec676bc --- /dev/null +++ b/ld/emulparams/elf32lriscv_ilp32.sh @@ -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 index 0000000..63304f9 --- /dev/null +++ b/ld/emulparams/elf32lriscv_ilp32f.sh @@ -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 diff --git a/ld/emulparams/elf64lriscv-defs.sh b/ld/emulparams/elf64lriscv-defs.sh index 6308714..930f333 100644 --- a/ld/emulparams/elf64lriscv-defs.sh +++ b/ld/emulparams/elf64lriscv-defs.sh @@ -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 diff --git a/ld/emulparams/elf64lriscv.sh b/ld/emulparams/elf64lriscv.sh index 3a6a652..f0a10ab 100644 --- a/ld/emulparams/elf64lriscv.sh +++ b/ld/emulparams/elf64lriscv.sh @@ -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 index 0000000..80a8f82 --- /dev/null +++ b/ld/emulparams/elf64lriscv_lp64.sh @@ -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 index 0000000..8f86421 --- /dev/null +++ b/ld/emulparams/elf64lriscv_lp64f.sh @@ -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 diff --git a/ld/genscripts.sh b/ld/genscripts.sh index 8732422..370b222 100755 --- a/ld/genscripts.sh +++ b/ld/genscripts.sh @@ -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} |