3.2. Symbol definitions and references

To ensure that an image includes all the required code and data, the linker must bind the unresolved symbol references in the input object files to definitions. When linking, it is normal to refer to a symbol rather than specifically to whether something is a function or variable.

A definition is where the linker loads the code for a function or variable. A reference is where a symbol is used, for example a function call or using a global variable. Take the following C code examples:

Example 3.1. 

extern void bar(void);

void foo(void)
{
    bar();
}

In this example the function foo is a definition and bar is a reference.


Example 3.2. 

int var;

int value(void)
{
    return var;
}

Here var and value are definitions.


During the linking process a linker must match a single definition to every reference. In Example 3.2 only a definition of var is required in the object file because var is defined in the same source file where it is used. In Example 3.1 the linker requires a definition of bar from another object file to resolve the reference to bar.

Copyright © 2010 ARM. All rights reserved.ARM DAI 0242A
Non-ConfidentialID011411