5. Diagnostics
Linker diagnostics refer to the messages and reports generated by a linker to help developers identify and resolve issues during the linking phase of compilation. These diagnostics can include:
Warnings and errors about malformed or unsupported linker scripts
Misplaced or overlapping sections
Unresolved symbols
Alignment issues
Plugin-related inconsistencies
5.1. What -Wall and -Werror Mean for ELD
5.1.1. -Wall
: Enable All Warnings
In the eld linker, -Wall
enables a broad set of diagnostic warnings during the linking process. These warnings help developers catch:
Misuse of linker script commands
Compatibility issues during linking
Linker script forward references
Suspicious section overlaps or misalignments
Deprecated or unsupported syntax
Potentially undefined behavior in symbol resolution
Command line usage
This flag is particularly useful in embedded development, where layout precision and deterministic behavior are critical.
5.1.2. -Werror
: Treat Warnings as Errors
When -Werror
is used, any warning promoted by -Wall
(or other -W
flags) is treated as a fatal error, halting the linking process. This ensures:
No warnings are ignored during CI/CD builds
Developers are forced to resolve all issues before producing a final binary
Consistency across builds, especially when linker behavior may vary across toolchain versions
This is especially important in embedded workflows, where eld is used to build critical components like firmware and device drivers.
5.1.3. Why It Matters in ELD
Embedded Safety: In embedded systems, even minor layout issues can lead to runtime faults.
-Wall -Werror
ensures these are caught early.Plugin Infrastructure: ELD supports linker plugins. These can emit custom diagnostics, and
-Wall
ensures they’re surfaced;-Werror
enforces them.Script Compatibility: ELD aims for GNU linker script compatibility. These flags help validate script correctness during migration from GNU ld.
5.1.4. Example Usage
eld -T script.ld -o firmware.elf main.o -Wall -Werror
This command will:
Use
script.ld
for layoutLink
main.o
intofirmware.elf
Emit all warnings (
-Wall
)Fail the build if any warning is encountered (
-Werror
)
What are the various categories that are grouped in
5.2. ELD Linker Warning Flags
This document provides a categorized list of warning flags supported by the ELD linker.
5.2.1. General Warning Flags
Flag |
Description |
---|---|
|
Enables all standard warnings supported by ELD. Useful for catching script and layout issues early. |
|
Warns about issues related to archive (.a) when they contain duplicate members. |
|
Flags inconsistent or conflicting section attributes across input files. |
|
Warns when the |
|
Enables warnings for malformed or conflicting command-line options. |
|
Treats all warnings as errors, halting the link process. |
|
Enables warnings specific to linker script issues, such as malformed directives, deprecated syntax, or unsupported constructs. |
|
Focuses on memory region definitions in linker scripts, such as overlaps or undefined regions. |
|
Warns when |
|
Flags sections that are defined but have zero size, which may indicate a script or input error. |
|
Generates a warning when an input file’s OS/ABI value differs from those encountered in previously processed files. |
5.2.2. Suppression Flags
Flag |
Description |
---|---|
|
Suppresses archive file-related warnings. |
|
Suppresses attribute mismatch warnings. |
|
Allows warnings to be emitted without halting the link process. |
|
Disables linker script-related warnings. |
|
Disables OS/ABI warnings. |