Function csx64::asm::link

source · []
pub fn link(
    objs: Vec<(String, ObjectFile)>,
    entry_point: Option<(&str, &str)>
) -> Result<Executable, LinkError>
Expand description

Attempts to link one or more (named) ObjectFiles into an Executable.

This function combines several incomplete object files together into a final, complete version. This starts with the first file, objs[0], and branches out to includes any extern symbols, recursively. Only files which are needed will be included in the final result.

The first object file, objs[0] is known as the “start file”. The start file’s text segment (starting at the beginning) is the first thing to execute upon running the resulting executable. For very basic programs this is fine, but using a higher-level framework might require setup prior to running the “main” logic. Typically, this is denoted by a generic symbol such as “start” (hence, start file). If entry_point is Some((from, to)), the linker will perform a renaming operation for identifiers in the start file (only).

If you wish to use the included C standard library functions, first call stdlib to get the object files, which includes its own start file at the front of the vec. Then, you need only add your object files to the end (with a global named “main” somewhere), and pass Some(("start", "main")).