10.10. Partial (Incremental) Linking

An output file that has been linked can be linked again with additional modules. This is known as partial linking or incremental linking. Partial linking allows you to partition large applications, link each part separately, and then link all the parts together to create the final executable program.

Follow these guidelines for producing a file that you will relink:

The following example shows how you can use partial linking:

Step 1: Link the file file1.com; use the --relocatable option to retain relocation information in the output file tempout1.out.

tiarmclang -Wl,--relocatable,--output_file=tempout1 file1.com

file1.com contains:

SECTIONS
{
    ss1: {
        f1.c.o
        f2.c.o
        .
        .
        .
        fn.c.o
    }
}

Step 2: Link the file file2.com; use the --relocatable option to retain relocation information in the output file tempout2.out.

tiarmclang -Wl,--relocatable,--output_file=tempout2 file2.com

file2.com contains:

SECTIONS
{
    ss2: {
        g1.c.o
        g2.c.o
        .
        .
        .
        gn.c.o
    }
}

Step 3: Link tempout1.out and tempout2.out.

tiarmclang -Wl,--map_file=final.map,--output_file=final.out tempout1.out tempout2.out