8.2 Compilation-Driver Linker Interface Syntax

In practice, the linker is usually invoked via xc32-gcc, the compilation driver. The basic form of the compilation-driver command line is:

xc32-gcc [options] files

The driver options are case sensitive. The files are one or more object files (.o extension) or library archive files (.a extension) which will be linked together to form the final output.

To pass a linker option to the linker without having to invoke the linker directly, use the driver's -Wl,option option. For example, the following will pass the --defsym option directly to the linker.
xc32-gcc -mprocessor=32MX360F512L "input.o" -o"output.elf"
-Os -Wl,--defsym=_min_heap_size=2048,-Map="mapfile.map",
--cref,--report-mem
Calling the linker via the compilation driver has a few advantages over calling the linker directly.
  • The driver's -mprocessor option allows the driver to pass the correct device-specific include-file and library search paths to the linker. For instance, when specifying -mprocessor=32MX360F512L, the driver passes the corresponding device-specific library search path, pic32mx/lib/proc/32MX360F512L, to the linker. This path allows the linker to find the correct default linker script and processor library for the target device.
  • The driver accepts the C compiler's options relating to ISA mode and floating-point support etc., to select the appropriate multilib permutation. See the C compiler User's Guide relevant for your target device for more information on the C compiler's multilib feature.