|
1 | 1 | # Using GNU linker ld
|
2 | 2 |
|
| 3 | +## ld flags |
3 | 4 |
|
4 |
| -ld -d `ld: no input files` |
5 |
| -ld -g `ld: no input files` |
| 5 | +My tests were done with doing these flags individually on a single command line. ld usually exists at /usr/bin/ld. My ld is GNU ld (GNU Binutils for Debian) 2.31.1. |
| 6 | + |
| 7 | +### Lowercase flags |
| 8 | + |
| 9 | +ld -d `ld: no input files` used to enable dynamic linking of libraries. tells the linker to generate dynamic rather than static object files |
| 10 | +ld -g `ld: no input files` used to generate debugging information in the output file. |
6 | 11 | ld -i `ld: no input files`
|
7 |
| -ld -m `ld: missing argument to -m` |
| 12 | +ld -m `ld: missing argument to -m` used to specify the output format. The argument to -m is the name of the output format, such as elf's |
8 | 13 | ld -n `ld: no input files`
|
9 | 14 | ld -q `ld: no input files`
|
10 |
| -ld -r `ld: no input files` |
| 15 | +ld -r `ld: no input files` used to generate a relocatable output file. |
11 | 16 | ld -s `ld: no input files`
|
12 |
| -ld -t `ld: no input files` |
| 17 | +ld -t `ld: no input files` used to generate debugging information in the output file. |
13 | 18 | ld -v reports the version
|
14 | 19 | ld -x `ld: no input files`
|
15 | 20 |
|
| 21 | +### Uppercase flags |
| 22 | + |
16 | 23 | ld -E `ld: no input files`
|
17 | 24 | ld -G `ld: no input files`
|
18 |
| -ld -M `ld: no input files` |
| 25 | +ld -M `ld: no input files` used to generate a map file that shows how the linker mapped input sections to output section |
19 | 26 | ld -N `ld: no input files`
|
20 | 27 | ld -Q `ld: no input files`
|
21 | 28 | ld -S `ld: no input files`
|
22 | 29 | ld -U `ld: no input files`
|
23 | 30 | ld -V returns the version plus supported emulations
|
24 |
| -ld -X `ld: no input files` |
| 31 | +ld -X `ld: no input files` |
| 32 | + |
| 33 | +## untested flags |
| 34 | + |
| 35 | +ld -T used to specifiy the linker file used |
| 36 | +ld -o Specifies the name of the output file (executable or library) to be generated |
| 37 | +ld -l Links against the specified library, searching for it in the standard library directories. |
| 38 | +ld -pie Creates a position-independent executable (PIE), which can be loaded at any address in memory |
| 39 | +ld -u Prevents garbage collection of the specified external symbol. |
| 40 | +ld -L Adds a directory to the library search path. |
| 41 | + |
| 42 | +## Use of ld |
| 43 | + |
| 44 | +`ld -T linker.script input1.o input2.o -o output` |
0 commit comments