8.4.7. Run-Time Environment Options

The options listed in the subsections below control how the linker manages the run-time environment. See Linking for Run-Time Initialization for more about the run-time environment.

On the c29clang command line they should be passed to the linker using the -Wl or -Xlinker option as described in Passing Options to the Linker.

8.4.7.1. Option Summary

--arg_size (--args)

Allocates memory to be used by the loader to pass arguments. See Allocate Memory for Use by the Loader to Pass Arguments (–arg_size Option).

--cinit_hold_wdt={on|off}

Hold (on) or do not hold (off) watchdog timer during cinit auto-initialization. See Initialization of Cinit and Watchdog Timer Hold.

--fill_value (-f)

Sets default fill values for holes within output sections; fill_value is a 32-bit constant. See Set Default Fill Value (--fill_value Option).

--ram_model (-cr)

Initializes variables at load time. See C Language Options (--ram_model and --rom_model Options).

--rom_model (-c)

Autoinitializes variables at run time. See C Language Options (--ram_model and --rom_model Options).

8.4.7.2. Allocate Memory for Use by the Loader to Pass Arguments (–arg_size Option)

The --arg_size option instructs the linker to allocate memory to be used by the loader to pass arguments from the command line of the loader to the program. The syntax of the --arg_size option is:

--arg_size = size

The size is the number of bytes to be allocated in target memory for command-line options.

By default, the linker creates the __c_args__ symbol and sets it to -1. When you specify --arg_size = size, the following occur:

  • The linker creates an uninitialized section named .args of size bytes.

  • The __c_args__ symbol contains the address of the .args section.

The loader and the target boot code use the .args section and the __c_args__ symbol to determine whether and how to pass arguments from the host to the target program. See Arguments to main for more information.

8.4.7.3. Set Default Fill Value (--fill_value Option)

The --fill_value option fills the holes formed within output sections. The syntax for the option is:

--fill_value=value

The argument value is a 32-bit constant (up to eight hexadecimal digits). If you do not use --fill_value, the linker uses 0 as the default fill value.

This example fills holes with the hexadecimal value ABCDABCD:

c29clang -Wl,--fill_value=0xABCDABCD file1.c.o file2.c.o

8.4.7.4. C Language Options (--ram_model and --rom_model Options)

The --ram_model and --rom_model options cause the linker to use linking conventions that are required by the C compiler. Both options inform the linker that the program is a C program and requires a boot routine.

  • The --ram_model option tells the linker to initialize variables at load time.

  • The --rom_model option tells the linker to autoinitialize variables at run time.

No default startup model is specified to the linker when the c29clang compiler runs the linker. Therefore, either the --rom_model (-c) or --ram_model (-cr) option must be passed to the linker on the c29clang command line using the -Wl or -Xlinker option or in the linker command file. For example:

c29clang -mcpu=c29.c0 hello.c -o hello.out -Wl,-c,-llnk.cmd,-mhello.map

If neither the -c or -cr option is specified to c29clang when running the linker, the linker expects an entry point for the linked application to be identified (using the -e=<symbol> linker option). If -c or -cr is specified, then the linker assumes that the program entry point is _c_int00, which performs any needed auto-initialization and system setup, then calls the user’s main() function.

For more information, see Linking C/C++ Code, Autoinitializing Variables at Run Time (--rom_model), and Initializing Variables at Load Time (--ram_model).