This blog post was originally published at Qualcomm’s website. It is reprinted here with the permission of Qualcomm.
At Qualcomm Technologies, Inc., embedded linkers play a crucial role in our software stack. While many linkers work well on traditional platforms, they often fall short when it comes to embedded systems.
Embedded projects have unique requirements, such as:
- Heavy reliance on linker scripts, which are not typically a concern in host linking.
- Complex use cases that often require custom extensions to linker functionality or linker scripts, tailored to meet specific customer needs.
To address these challenges, we developed a linker called eld, which is derived from mclinker. This linker is designed to work with ELF files and is specifically tailored to meet the needs of the embedded community.
The eld linker is included in the Qualcomm compiler toolchains and leverages LLVM components and libraries wherever possible. Our customers rely on eld to build images that run on Qualcomm Technologies hardware.
We are excited to open source the eld linker! Our goal is to collaborate with the linker and system software communities to develop new features and enhance its capabilities. Download eld from GitHub
Features
The linker is fully compliant with GNU standards, encompassing the reading of input files, symbol resolution, and the generation of GNU-compliant output.
The linker supports the following targets:
- AArch32 and AArch64
- Qualcomm Hexagon NPU
- RISC-V (including the Xqiu extension)
The linker incorporates various features commonly available in GNU-compliant linkers, including:
- Partial linking
- Dynamic linking
- Static linking
- Link Time Optimization (LTO)
- Linker optimizations such as string merging
Additionally, the linker offers mature support for linker scripts with custom extensions.
Extended Features
The linker also includes numerous features aimed at enhancing user experience, such as:
- Easy-to-read linker map files: Our customer support team extensively utilizes this information to diagnose and resolve issues. These map files are also machine-readable, enabling customers to generate custom reports from the images they build.
- Easy reproduction of link-time issues: A unique method for customers to share artifacts used at link time when encountering link-time issues.
- Comprehensive diagnostic options: Provides extensive debugging capabilities for complex issues such as symbol garbage collection, command-line issues, warnings, and errors.
Linker Plugins
In response to increasing customer demand for inspecting and altering image layouts, extending linker functionality for unanticipated use cases, and generating custom reports, we have developed linker plugins.
These plugins allow customers to create custom passes that run during link time, offering complete user control and management by the linker, with a focus on diagnostics.
The plugin infrastructure also allows toolchain developers to treat the linker as a transparent component, facilitating the careful management of assumptions in the image, emitting errors or warnings if assumptions are violated, and encoding information in source code for linker consumption.
This infrastructure also assists compiler developers with layout decisions, enabling them to:
- Pass auxiliary information from the compiler to the linker
- Optimize image layout for specific use cases
Qualcomm Technologies Products Utilizing the Linker
The linker is employed in various Qualcomm Technologies’ products, including:
- Qualcomm AI software infrastructure
- Qualcomm 5G modems
- Wireless LAN products and drivers
- Qualcomm firmware and device drivers
- Qualcomm Audio drivers
- TrustZone
- Numerous AArch32/AArch64/RISC-V images utilizing Zephyr RTOS
- Various microcontroller images based on RISC-V
Linker Source Organization
The linker source code is categorized into three major sections:
- Core Linker (divided into functionally specific directories)
- Target-specific overrides
- Unit tests
The core linker encompasses the most critical features, while the target-specific overrides facilitate the customization of functionality provided by the core linker.
This encapsulation allows developers to modify and enhance target-specific functionality without impacting other targets.
The unit tests are divided into two categories:
- Unit testing using Google Unit Tests
- Lit tests using the LLVM lit test framework
Testing
The linker includes a comprehensive set of unit test cases that are designed to be easily readable and modifiable. These tests cover both the linker itself and various linker plugin examples, helping customers understand the robust linker plugin infrastructure.
Our team also performs testing for internal applications on both simulated and on-device platforms.
The linker is accompanied by comprehensive user-facing documentation that elucidates linker behavior, as well as a thorough FAQ addressing common problems and solutions.
Connect with us
The team is dedicated to continually assessing and introducing features that focus on the embedded community.
We invite you to join our efforts in improving the linker and making the solution better. Please feel free to open any issues you would like to work on on GitHub or share use cases that we do not currently support.
Closing Remarks
We hope that the embedded linker solution addresses the use cases you are aiming to solve.
We would also like to acknowledge the eld team and our entire LLVM team for their continuous contributions to enhancing the linker.
If you have any thoughts to share or would like to speak with us, please do not hesitate to reach out to our team on GitHub.
Shankar Kalpathi Easwaran
Principal Engineer, Qualcomm Technologies