PROPHET/OS
NAME
ld: links relocatable objects into a program
SYNOPSIS
ld -T <script> [-o <file>] [--defsym <name>=<number>] [--emit-relocs] [--oformat binary] <object> ... ld selbsttest
DESCRIPTION
Links relocatable objects into a program
The linker of this tree (R10-SELF-03). It reads the script, places the sections of the objects in the order of its lines, then of the files, then of their sections, each at its own alignment, resolves the symbols between the objects and applies the relocations. Gaps inside code are filled with no-op instructions, gaps in data stay zero.
The script may use what the scripts of the tree use: ENTRY, INCLUDE, assignments to a symbol or to ., output sections with (NOLOAD) and AT(...), input patterns with *, ? and [a-z], KEEP, BYTE to QUAD and /DISCARD/. A section that carries bytes and no line places is refused by name, and so is anything else the script reader does not know.
--oformat binary writes the flat image, from the lowest load address that carries bytes to the last byte; without it the linked ELF is written, and --emit-relocs keeps the relocations in it. -n, -nostdlib and --no-warn-rwx-segments are taken and change nothing.
The relocation kinds are the six the objects of this tree carry: R_X86_64_64, _PC32, _PLT32, _32, _32S and _16, and _NONE, which patches nothing. A value that does not fit its kind is refused with the symbol it names.
An output section that comes out empty goes; the symbols assigned inside it lie at the address it would have had. An ENTRY nobody defines is refused. A link that is refused leaves no output file.
On success it says how many bytes it wrote, how many input sections of how many objects went into how many output sections, and how many symbols and relocations the ELF keeps.
selbsttest links two objects it writes itself, with one relocation of each kind, and holds every byte against the address it has to name; it links what nobody defines, what no line places and a value too wide for its kind and expects a refusal; and it links the objects of pshell that the build laid under /media/checks/proben/ld with the line of the build, and holds the image against the one of the host linker byte for byte. It is what ld.a_program_of_the_tree_links_here_to_the_host_image drives.
EXAMPLE
$ ld --help ld -T <script> [-o <file>] [--defsym <name>=<number>] [--emit-relocs] [--oformat binary] <object> ... ld selbsttest places the sections of relocatable objects by the script, resolves their symbols and applies their relocations