Expand description
The start files, the libraries and the loader for one target’s link.
Design: spec/cross-compile/08-sysroots.md section 8.2 and spec/cross-compile/11-linking.md.
What is here is what has to be linked, in what order, and which loader will start the result.
How that is spelled for a particular linker is crate::argv, which is the division
spec/cross-compile/11-linking.md draws: the files are a fact about the target and the flags are
a fact about the linker.
§Why musl is first
spec/cross-compile/09-libc-stubs.md section 9.3 is the argument. musl exercises the header
tree, the search paths, the start files, the compiler runtime and the link line, and it does
that without symbol versioning and without stub generation, which are the two hardest pieces of
the glibc path. If a musl cross link works end to end then the pipeline is right and what is
left for M9.5 is the glibc specific parts rather than the shape of the thing.
§Why the line has three parts and not one
crtn.o goes after the libraries and crti.o goes before them, because between them they open
and close the .init and .fini sections and anything contributing to those has to land in the
middle. A link line that is one list gets this wrong in a way that produces a binary which links,
runs, and does not run its static constructors, so the three parts are three fields here rather
than a comment on an ordering somebody has to preserve.
Structs§
- Link
Line - The inputs to a link, in the three groups a linker needs them in.
Enums§
- Libc
- What a produced sysroot holds for a target’s C library.
- Link
Mode - How the program is linked, which decides the first start file and the flags.
Constants§
- BUILTINS
- Our own runtime library, which every one of the three lines below carries.
Functions§
- glibc_
loader - The absolute path glibc’s loader is installed at on the target.
- libc
- Which of the four cases this target is.
- loader
- The absolute path the target’s loader is installed at, or
Nonefor a target that has none. - musl_
loader - The absolute path musl’s loader is installed at on the target.