From 006449b6d54864d0c2b9757da8d9ce1c2c126a47 Mon Sep 17 00:00:00 2001 From: Fatima Saleem Date: Sun, 15 May 2022 03:52:39 +0500 Subject: [PATCH] added linker as an argument of cva6.py --- cva6/regress/dv-riscv-arch-test.sh | 2 +- cva6/regress/install-cva6.sh | 2 +- cva6/sim/cva6.py | 42 ++++++++++++++++++------------ cva6/sim/link.ld | 4 +-- 4 files changed, 28 insertions(+), 22 deletions(-) diff --git a/cva6/regress/dv-riscv-arch-test.sh b/cva6/regress/dv-riscv-arch-test.sh index a534866b9f..6a77246b32 100644 --- a/cva6/regress/dv-riscv-arch-test.sh +++ b/cva6/regress/dv-riscv-arch-test.sh @@ -28,5 +28,5 @@ if ! [ -n "$DV_SIMULATORS" ]; then fi cd cva6/sim -python3 cva6.py --testlist=../tests/testlist_riscv-arch-test-$DV_TARGET.yaml --target $DV_TARGET --iss_yaml=cva6.yaml --iss=$DV_SIMULATORS $DV_OPTS +python3 cva6.py --testlist=../tests/testlist_riscv-arch-test-$DV_TARGET.yaml --target $DV_TARGET --iss_yaml=cva6.yaml --iss=$DV_SIMULATORS $DV_OPTS --linker=../tests/riscv-isa-sim/arch_test_target/spike/link.ld cd - diff --git a/cva6/regress/install-cva6.sh b/cva6/regress/install-cva6.sh index a06b63b1d2..4c410b9c67 100755 --- a/cva6/regress/install-cva6.sh +++ b/cva6/regress/install-cva6.sh @@ -37,7 +37,7 @@ export NUM_JOBS=24 if ! [ -n "$CVA6_REPO" ]; then CVA6_REPO="https://github.com/openhwgroup/cva6.git" CVA6_BRANCH="master" - CVA6_HASH="34f63b44873148d371133bfa8642d2b7d388f39b" + CVA6_HASH="75807530f26ba9a0ca501e9d3a6575ec375ed7ab" CVA6_PATCH= fi echo $CVA6_REPO diff --git a/cva6/sim/cva6.py b/cva6/sim/cva6.py index 34c990b486..fb14e01ba7 100644 --- a/cva6/sim/cva6.py +++ b/cva6/sim/cva6.py @@ -329,7 +329,7 @@ def elf2bin(elf, binary, debug_cmd): run_cmd_output(cmd.split(), debug_cmd = debug_cmd) -def gcc_compile(test_list, output_dir, isa, mabi, opts, debug_cmd): +def gcc_compile(test_list, output_dir, isa, mabi, opts, debug_cmd, linker): """Use riscv gcc toolchain to compile the assembly program Args: @@ -338,6 +338,7 @@ def gcc_compile(test_list, output_dir, isa, mabi, opts, debug_cmd): isa : ISA variant passed to GCC mabi : MABI variant passed to GCC debug_cmd : Produce the debug cmd log without running + linker : Path to the linker """ cwd = os.path.dirname(os.path.realpath(__file__)) for test in test_list: @@ -357,8 +358,8 @@ def gcc_compile(test_list, output_dir, isa, mabi, opts, debug_cmd): -fvisibility=hidden -nostdlib \ -nostartfiles %s \ -I%s/dv/user_extension \ - -T%s/link.ld %s -o %s " % \ - (get_env_var("RISCV_GCC", debug_cmd = debug_cmd), asm, cwd, cwd, opts, elf)) + -T%s %s -o %s " % \ + (get_env_var("RISCV_GCC", debug_cmd = debug_cmd), asm, cwd, linker, opts, elf)) if 'gcc_opts' in test: cmd += test['gcc_opts'] if 'gen_opts' in test: @@ -377,7 +378,7 @@ def gcc_compile(test_list, output_dir, isa, mabi, opts, debug_cmd): def run_assembly(asm_test, iss_yaml, isa, target, mabi, gcc_opts, iss_opts, output_dir, - setting_dir, debug_cmd): + setting_dir, debug_cmd, linker): """Run a directed assembly test with ISS Args: @@ -390,6 +391,7 @@ def run_assembly(asm_test, iss_yaml, isa, target, mabi, gcc_opts, iss_opts, outp output_dir : Output directory of compiled test files setting_dir : Generator setting directory debug_cmd : Produce the debug cmd log without running + linker : Path to the linker """ if not asm_test.endswith(".S"): logging.error("%s is not an assembly .S file" % asm_test) @@ -413,9 +415,9 @@ def run_assembly(asm_test, iss_yaml, isa, target, mabi, gcc_opts, iss_opts, outp -fvisibility=hidden -nostdlib \ -nostartfiles %s \ -I%s/dv/user_extension \ - -T%s/link.ld %s -o %s " % \ - (get_env_var("RISCV_GCC", debug_cmd = debug_cmd), asm_test, cwd, - cwd, gcc_opts, elf)) + -T%s %s -o %s " % \ + (get_env_var("RISCV_GCC", debug_cmd = debug_cmd), asm_test, cwd, linker, + gcc_opts, elf)) cmd += (" -march=%s" % isa) cmd += (" -mabi=%s" % mabi) run_cmd_output(cmd.split(), debug_cmd = debug_cmd) @@ -457,7 +459,7 @@ def run_assembly_from_dir(asm_test_dir, iss_yaml, isa, mabi, gcc_opts, iss, (len(asm_list), asm_test_dir)) for asm_file in asm_list: run_assembly(asm_file, iss_yaml, isa, target, mabi, gcc_opts, iss, output_dir, - setting_dir, debug_cmd) + setting_dir, debug_cmd, linker) if "," in iss: report = ("%s/iss_regr.log" % output_dir).rstrip() save_regr_report(report) @@ -514,7 +516,7 @@ def run_elf(c_test, iss_yaml, isa, target, mabi, gcc_opts, iss_opts, output_dir, def run_c(c_test, iss_yaml, isa, target, mabi, gcc_opts, iss_opts, output_dir, - setting_dir, debug_cmd): + setting_dir, debug_cmd, linker): """Run a directed c test with ISS Args: @@ -527,6 +529,7 @@ def run_c(c_test, iss_yaml, isa, target, mabi, gcc_opts, iss_opts, output_dir, output_dir : Output directory of compiled test files setting_dir : Generator setting directory debug_cmd : Produce the debug cmd log without running + linker : Path to the linker """ if not c_test.endswith(".c"): logging.error("%s is not a .c file" % c_test) @@ -547,9 +550,9 @@ def run_c(c_test, iss_yaml, isa, target, mabi, gcc_opts, iss_opts, output_dir, cmd = ("%s -mcmodel=medany -nostdlib \ -nostartfiles %s \ -I%s/dv/user_extension \ - -T%s/link.ld %s -o %s " % \ + -T%s %s -o %s " % \ (get_env_var("RISCV_GCC", debug_cmd = debug_cmd), c_test, cwd, - cwd, gcc_opts, elf)) + linker, gcc_opts, elf)) cmd += (" -march=%s" % isa) cmd += (" -mabi=%s" % mabi) run_cmd_output(cmd.split(), debug_cmd = debug_cmd) @@ -591,7 +594,7 @@ def run_c_from_dir(c_test_dir, iss_yaml, isa, mabi, gcc_opts, iss, (len(c_list), c_test_dir)) for c_file in c_list: run_c(c_file, iss_yaml, isa, target, mabi, gcc_opts, iss, output_dir, - setting_dir, debug_cmd) + setting_dir, debug_cmd, linker) if "," in iss: report = ("%s/iss_regr.log" % output_dir).rstrip() save_regr_report(report) @@ -811,6 +814,8 @@ def setup_parser(): help="Generate debug command log file") parser.add_argument("--hwconfig_opts", type=str, default="", help="custom configuration options, to be passed in config_pkg_generator.py in cva6") + parser.add_argument("-l", "--linker", type=str, default="", + help="Path for the link.ld") return parser @@ -833,6 +838,9 @@ def load_config(args, cwd): if not args.simulator_yaml: args.simulator_yaml = cwd + "/cva6-simulator.yaml" + if not args.linker: + args.linker = cwd + "/link.ld" + # Keep the core_setting_dir option to be backward compatible, suggest to use # --custom_target if args.core_setting_dir: @@ -958,7 +966,7 @@ def main(): # path_asm_test is an assembly file elif os.path.isfile(full_path) or args.debug: run_assembly(full_path, args.iss_yaml, args.isa, args.target, args.mabi, args.gcc_opts, - args.iss, output_dir, args.core_setting_dir, args.debug) + args.iss, output_dir, args.core_setting_dir, args.debug, args.linker) else: logging.error('%s does not exist' % full_path) sys.exit(RET_FAIL) @@ -977,7 +985,7 @@ def main(): # path_c_test is a c file elif os.path.isfile(full_path) or args.debug: run_c(full_path, args.iss_yaml, args.isa, args.target, args.mabi, args.gcc_opts, - args.iss, output_dir, args.core_setting_dir, args.debug) + args.iss, output_dir, args.core_setting_dir, args.debug, args.linker) else: logging.error('%s does not exist' % full_path) sys.exit(RET_FAIL) @@ -1068,7 +1076,7 @@ def main(): # path_asm_test is an assembly file elif os.path.isfile(path_asm_test): run_assembly(path_asm_test, args.iss_yaml, args.isa, args.target, args.mabi, gcc_opts, - args.iss, output_dir, args.core_setting_dir, args.debug) + args.iss, output_dir, args.core_setting_dir, args.debug, args.linker) else: if not args.debug: logging.error('%s does not exist' % path_asm_test) @@ -1089,7 +1097,7 @@ def main(): # path_c_test is a C file elif os.path.isfile(path_c_test): run_c(path_c_test, args.iss_yaml, args.isa, args.target, args.mabi, gcc_opts, - args.iss, output_dir, args.core_setting_dir, args.debug) + args.iss, output_dir, args.core_setting_dir, args.debug, args.linker) else: if not args.debug: logging.error('%s does not exist' % path_c_test) @@ -1102,7 +1110,7 @@ def main(): # Compile the assembly program to ELF, convert to plain binary if args.steps == "all" or re.match(".*gcc_compile.*", args.steps): gcc_compile(matched_list, output_dir, args.isa, args.mabi, - args.gcc_opts, args.debug) + args.gcc_opts, args.debug, args.linker) # Run ISS simulation if args.steps == "all" or re.match(".*iss_sim.*", args.steps): diff --git a/cva6/sim/link.ld b/cva6/sim/link.ld index 553db2a0cf..ad50f56e2e 100644 --- a/cva6/sim/link.ld +++ b/cva6/sim/link.ld @@ -14,7 +14,7 @@ */ OUTPUT_ARCH( "riscv" ) -ENTRY(rvtest_entry_point) +ENTRY(_start) SECTIONS { @@ -30,8 +30,6 @@ SECTIONS .kernel_data : { *(.kernel_data) } .kernel_stack : { *(.kernel_stack) } .data : { *(.data) } - .data.string : { *(.data.string)} .bss : { *(.bss) } _end = .; } -