You copied the Doc URL to your clipboard.

Passing options from the compiler to the linker

By default, when you run armclang the compiler automatically invokes the linker, armlink.

A number of armclang options control the behavior of the linker. These options are translated to equivalent armlink options.

Table 2-11 armclang linker control options

armclang Option armlink Option Description
-e --entry Specifies the unique initial entry point of the image.
-L --userlibpath Specifies a list of paths that the linker searches for user libraries.
-l --library Add the specified library to the list of searched libraries.
-u --undefined Prevents the removal of a specified symbol if it is undefined.

In addition, the -Xlinker and -Wl options let you pass options directly to the linker from the compiler command line. These options perform the same function, but use different syntaxes:

  • The -Xlinker option specifies a single option, a single argument, or a single option=argument pair. If you want to pass multiple options, use multiple -Xlinker options.

  • The -Wl, option specifies a comma-separated list of options and arguments or option=argument pairs.

For example, the following are all equivalent because armlink treats the single option --list=diag.txt and the two options --list diag.txt equivalently:

-Xlinker --list -Xlinker diag.txt -Xlinker --split

-Xlinker --list=diag.txt -Xlinker --split

-Wl,--list,diag.txt,--split

-Wl,--list=diag.txt,--split

Note

The -### compiler option produces diagnostic output showing exactly how the compiler and linker are invoked, displaying the options for each tool. With the -### option, armclang only displays this diagnostic output. It does not compile source files or invoke armlink.

The following example shows how to use the -Xlinker option to pass the --split option to the linker, splitting the default load region containing the RO and RW output sections into separate regions:

armclang hello.c --target=aarch64-arm-none-eabi  -Xlinker --split

You can use fromelf --text to compare the differences in image content:

armclang hello.c --target=aarch64-arm-none-eabi -o hello_DEFAULT.axf
armclang hello.c --target=aarch64-arm-none-eabi -o hello_SPLIT.axf -Xlinker --split

fromelf --text hello_DEFAULT.axf > hello_DEFAULT.txt
fromelf --text hello_SPLIT.axf > hello_SPLIT.txt
Was this page helpful? Yes No