fn link_binary_riscv(testprogram: &TestProgram, riscv_address: &Memory) -> Result<(), BuildError> {
    let working_dir = testprogram.path.to_owned().join("riscv/");

    // Check if object file exists
    if !working_dir.to_owned().join("main.o").exists() {
        return Err(BuildError::ObjectFileNotFound);
    }

    let link = Command::new("riscv-none-embed-ld")
        .args([
            "main.o",
            "-o",
            &format!("main_{:#x}_{:#x}.elf", riscv_address.nvm.start, riscv_address.ram.start),
            "-b",
            "elf32-littleriscv",
            "-Ttext",
            &format!("{:#x}", riscv_address.nvm.start),
            "-Tdata",
            &format!("{:#x}", riscv_address.ram.start),
        ])
        .current_dir(working_dir)
        .output()
        .expect("Failed to run the RISCV linking process, is the riscv-none-embed-ld command accessible to the application?");

    if !link.status.success() {
        let cause;

        if !link.stderr.is_empty() {
            cause = String::from_utf8(link.stderr)
                .expect("Failed to parse stderr from RISCV linker to string");
        } else {
            cause = String::from_utf8(link.stdout)
                .expect("Failed to parse stdout from RISCV linker to string");
        }

        return Err(BuildError::LinkingError(cause));
    }

    Ok(())
}
/// Try to link the previously generated objectfile to a final RISCV elf file with the provided memory address mapping
///
/// The final elf is stored in the following format, to distinguish it between other memory address mappings:
///
/// main_`flash start address`_`ram start address`.elf
Try to link the previously generated objectfile to a final RISCV elf file with the provided memory address mapping
The final elf is stored in the following format, to distinguish it between other memory address mappings.

main_`flash start address`_`ram start address`.elf
Try to link the previously generated objectfile to a final RISCV elf file with the provided memory address mapping The final elf is stored in the following format to distinguish it between other memory address mappings . main_ ` flash start address ` _ ` ram start address ` . elf
fn link_binary_riscv(testprogram: &TestProgram, riscv_address: &Memory) -> Result<(), BuildError> {
    let working_dir = testprogram.path.to_owned().join("riscv/");
    // Check if object file exists
    if !working_dir.to_owned().join("main.o").exists() {
        return Err(BuildError::ObjectFileNotFound);
    }
    let link = Command::new("riscv-none-embed-ld")
        .args([
            "main.o",
            "-o",
            &format!("main_{:#x}_{:#x}.elf", riscv_address.nvm.start, riscv_address.ram.start),
            "-b",
            "elf32-littleriscv",
            "-Ttext",
            &format!("{:#x}", riscv_address.nvm.start),
            "-Tdata",
            &format!("{:#x}", riscv_address.ram.start),
        ])
        .current_dir(working_dir)
        .output()
        .expect("Failed to run the RISCV linking process, is the riscv-none-embed-ld command accessible to the application?");
    if !link.status.success() {
        let cause;
        if !link.stderr.is_empty() {
            cause = String::from_utf8(link.stderr)
                .expect("Failed to parse stderr from RISCV linker to string");
        } else {
            cause = String::from_utf8(link.stdout)
                .expect("Failed to parse stdout from RISCV linker to string");
        }
        return Err(BuildError::LinkingError(cause));
    }
    Ok(())
}
fn link_binary_riscv ( testprogram : & TestProgram , riscv_address : & Memory ) -> Result < ( ) , BuildError > { let working_dir = testprogram . path . to_owned ( ) . join ( " " ) ; // Check if object file exists if ! working_dir . to_owned ( ) . join ( " " ) . exists ( ) { return Err ( BuildError :: ObjectFileNotFound ) ; } let link = Command :: new ( " " ) . args ( [ " " , " " , & format ! ( " " riscv_address nvm start riscv_address ram start ) , " " , " " , " " , & format ! ( " " riscv_address nvm start ) , " " , & format ! ( " " riscv_address ram start ) , ] ) . current_dir ( working_dir ) . output ( ) . expect ( " " ) ; if ! link . status . success ( ) { let cause ; if ! link . stderr . is_empty ( ) { cause = String :: from_utf8 ( link . stderr ) . expect ( " " ) ; } else { cause = String :: from_utf8 ( link . stdout ) . expect ( " " ) ; } return Err ( BuildError :: LinkingError ( cause ) ) ; } Ok ( ( ) ) }
Try to link the previously generated objectfile to a final RISCV elf file with the provided memory address mapping
The final elf is stored in the following format, to distinguish it between other memory address mappings:
Try to link the previously generated objectfile to a final RISCV elf file with the provided memory address mapping The final elf is stored in the following format to distinguish it between other memory address mappings :
testprogram
&TestProgram
riscv_address
&Memory