ELD (debugging guide) ========================= This document describes the high-level flow of how ELD executes a link, with call-site pointers and practical tips for debugging failures. .. contents:: :local: Big picture ----------- At a high level, a link invocation looks like this: 1. **eld main** expands response files and selects a driver flavor/target. 2. **Driver** parses options and builds an ordered list of input actions. 3. **Linker prepare** initializes target/emulation, inputs, and plugins, then reads and normalizes input files (and may run LTO). 4. **Linker link** resolves symbols/relocations, lays out output sections, then emits the final ELF and optional map files. 5. **Optional diagnostics**: reproduce tarball/mapping file, plugin activity log, timing stats, summary, etc. Entry point and driver selection -------------------------------- The executable entry point is ``tools/eld/eld.cpp``: * Expands ``@response`` files via ``llvm::cl::ExpandResponseFiles(...)``. * Creates a ``Driver`` and calls ``Driver::setDriverFlavorAndInferredArchFromLinkCommand(...)``. * Creates a GNU-ld-compatible driver (``GnuLdDriver``) and calls ``GnuLdDriver::link(...)``. Driver flavor selection is implemented in ``lib/LinkerWrapper/Driver.cpp``: * First tries to infer a target from the program name (e.g. ``arm-link``, ``aarch64-link``, ``hexagon-link``). * Otherwise inspects early arguments like ``-m `` or ``-march`` to select a target-specific driver. Environment hooks that affect arguments: * ``ELDFLAGS``: appended to the link command by the driver (useful for always-on debug flags). Argument parsing and preprocessing ---------------------------------- The top-level flow of option parsing and dispatch is in ``lib/LinkerWrapper/GnuLdDriver.cpp`` (``GnuLdDriver::link(...)``): 1. ``parseOptions(...)`` 2. ``processLLVMOptions(...)`` (parses ``-mllvm ...`` arguments) 3. ``processTargetOptions(...)`` (handles ``-mtriple``, ``-march``, ``-mabi``, ``-m ``, etc.) 4. ``processOptions(...)`` (general linker options) 5. ``checkOptions(...)`` and ``overrideOptions(...)`` 6. ``createInputActions(...)`` to build the ordered action list 7. ``doLink(...)`` to run the actual link pipeline If you suspect argument/option issues, start with: * ``--verbose`` (or ``--verbose=``) * ``--trace=command-line`` * ``--trace=files`` or ``-t`` (prints processed files) * ``--error-style=GNU`` or ``--error-style=LLVM`` (if output formatting matters) Input actions (what gets fed to the linker) ------------------------------------------- After parsing options, the driver builds a sequence of actions that are later "activated" to create inputs: * ``-T