summaryrefslogtreecommitdiffstats
path: root/c/src
diff options
context:
space:
mode:
authorHesham Almatary <Hesham.Almatary@cl.cam.ac.uk>2019-10-23 12:43:17 +0100
committerHesham Almatary <Hesham.Almatary@cl.cam.ac.uk>2019-10-27 10:45:00 +0000
commitf462bcbb0a2cf6030bf2420aae0e083856bf3a53 (patch)
treefa790631c01d2690abf438634dcb596eedc408fc /c/src
parentriscv: Generate linkcmds.base from the shared linkcmds.base.in (diff)
downloadrtems-f462bcbb0a2cf6030bf2420aae0e083856bf3a53.tar.bz2
riscv: Address differences in the linkerscript between GNU LD and LLVM/LLD
LLVM/LLD does not support STARTUP and ALIGN_WITH_INPUT directives that GNU LD support. INPUT and ALIGN(8) are supported by LLVM/LLD and can replace the unsupported STARTUP/ALIGN_WITH_INPUT directives. The commit conditionally adds the supported directive that linkers can understand depending on the toolchain used to compile RTEMS i.e., clang or gcc. Clang is assumed to use LLD by default.
Diffstat (limited to 'c/src')
-rw-r--r--c/src/lib/libbsp/riscv/griscv/Makefile.am2
-rw-r--r--c/src/lib/libbsp/riscv/griscv/configure.ac19
-rw-r--r--c/src/lib/libbsp/riscv/riscv/configure.ac13
3 files changed, 33 insertions, 1 deletions
diff --git a/c/src/lib/libbsp/riscv/griscv/Makefile.am b/c/src/lib/libbsp/riscv/griscv/Makefile.am
index 4077ddebd2..e04598e4bf 100644
--- a/c/src/lib/libbsp/riscv/griscv/Makefile.am
+++ b/c/src/lib/libbsp/riscv/griscv/Makefile.am
@@ -23,7 +23,7 @@ start.$(OBJEXT): ../../../../../../bsps/riscv/shared/start/start.S
project_lib_DATA = start.$(OBJEXT)
project_lib_DATA += linkcmds
-project_lib_DATA += ../../../../../../bsps/riscv/shared/start/linkcmds.base
+project_lib_DATA += linkcmds.base
###############################################################################
# LibBSP #
diff --git a/c/src/lib/libbsp/riscv/griscv/configure.ac b/c/src/lib/libbsp/riscv/griscv/configure.ac
index ed5694c763..a92676169f 100644
--- a/c/src/lib/libbsp/riscv/griscv/configure.ac
+++ b/c/src/lib/libbsp/riscv/griscv/configure.ac
@@ -30,11 +30,30 @@ AC_ARG_VAR([$1],[$2])dnl
[$1]=[$]{[$1]:-[$3]}
])
+case "${RTEMS_BSP}" in
+ *clang)
+ RISCV_LINKER_START_DIRECTIVE_DEFAULT="INPUT"
+ RISCV_LINKER_ALIGN_DIRECTIVE_DEFAULT="ALIGN(8)"
+ ;;
+ *)
+ RISCV_LINKER_START_DIRECTIVE_DEFAULT="STARTUP"
+ RISCV_LINKER_ALIGN_DIRECTIVE_DEFAULT="ALIGN_WITH_INPUT"
+ ;;
+esac
+
+AC_DEFUN([RISCV_LINKCMD],[
+AC_ARG_VAR([$1],[$2])dnl
+[$1]=[$]{[$1]:-[$3]}
+])
+
RISCV_LINKCMD([RISCV_RAM_REGION_BEGIN],[begin of the RAM region for linker command file (default is 0x40000000)],[${RISCV_RAM_REGION_BEGIN_DEFAULT}])
RISCV_LINKCMD([RISCV_RAM_REGION_SIZE],[size of the RAM region for linker command file (default 16MiB)],[0x01000000])
+RISCV_LINKCMD([RISCV_LINKER_START_DIRECTIVE],[GNU LD understands STARTUP directive while LLVM/LLD does not and needs INPUT instead],[${RISCV_LINKER_START_DIRECTIVE_DEFAULT}])
+RISCV_LINKCMD([RISCV_LINKER_ALIGN_DIRECTIVE],[LLD does not support ALIGN_WITH_INPUT directive],[${RISCV_LINKER_ALIGN_DIRECTIVE_DEFAULT}])
AC_CONFIG_FILES([
Makefile
linkcmds:../../../../../../bsps/riscv/griscv/start/linkcmds.in
+linkcmds.base:../../../../../../bsps/riscv/shared/start/linkcmds.base.in
])
AC_OUTPUT
diff --git a/c/src/lib/libbsp/riscv/riscv/configure.ac b/c/src/lib/libbsp/riscv/riscv/configure.ac
index af501badf2..4494a03536 100644
--- a/c/src/lib/libbsp/riscv/riscv/configure.ac
+++ b/c/src/lib/libbsp/riscv/riscv/configure.ac
@@ -67,6 +67,17 @@ case "${RTEMS_BSP}" in
;;
esac
+case "${RTEMS_BSP}" in
+ *clang)
+ RISCV_LINKER_START_DIRECTIVE_DEFAULT="INPUT"
+ RISCV_LINKER_ALIGN_DIRECTIVE_DEFAULT="ALIGN(8)"
+ ;;
+ *)
+ RISCV_LINKER_START_DIRECTIVE_DEFAULT="STARTUP"
+ RISCV_LINKER_ALIGN_DIRECTIVE_DEFAULT="ALIGN_WITH_INPUT"
+ ;;
+esac
+
AC_DEFUN([RISCV_LINKCMD],[
AC_ARG_VAR([$1],[$2])dnl
[$1]=[$]{[$1]:-[$3]}
@@ -74,6 +85,8 @@ AC_ARG_VAR([$1],[$2])dnl
RISCV_LINKCMD([RISCV_RAM_REGION_BEGIN],[begin of the RAM region for linker command file (default is 0x70000000 for 64-bit with -mcmodel=medlow and 0x80000000 for all other)],[${RISCV_RAM_REGION_BEGIN_DEFAULT}])
RISCV_LINKCMD([RISCV_RAM_REGION_SIZE],[size of the RAM region for linker command file (default is 256 MiB for frdme310arty and 64 MiB for all other)],[${RISCV_RAM_REGION_SIZE_DEFAULT}])
+RISCV_LINKCMD([RISCV_LINKER_START_DIRECTIVE],[GNU LD understands STARTUP directive while LLVM/LLD does not and needs INPUT instead],[${RISCV_LINKER_START_DIRECTIVE_DEFAULT}])
+RISCV_LINKCMD([RISCV_LINKER_ALIGN_DIRECTIVE],[LLD does not support ALIGN_WITH_INPUT directive],[${RISCV_LINKER_ALIGN_DIRECTIVE_DEFAULT}])
AC_CONFIG_FILES([
Makefile