Noeud:Passing Arguments to the Assembler and Linker, Noeud « Next »:, Noeud « Previous »:Link Editing And Libraries, Noeud « Up »:GCC Commands



Passing Arguments to the Assembler and Linker

Although uncommon, you can also pass arguments directly from gcc to the assembler and linker.

To pass arguments to the assembler, use the command

-Wa,option-list

And to pass arguments to the linker, use the command

-Wl,option-list

where option-list is a list of comma separated options (with no white-space between options whatsoever) to be passed to either process.

A useful option to pass to the linker is when certain runtime shared libraries cannot be found; use the -rpath PATH to set this. For example,

$ gcc -Wl,-rpath /usr/lib/crti.o

tells gcc to pass the option -rpath /usr/lib/crti.o to the linker, such that the linker looks at /usr/lib/crti.o to be included in the runtime search path. Since there are a variety of useful options that you can pass to both assembler and linker, we'll not list any here and be satisfied with having explained that it's at least possible. To view a full listing of either assembler or linker, try

process --help

where process is one of as (the assembler) or ld (the linker).