Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Adding support for s390x in LLD, the LLVM linker

June 18, 2024
Tulio Magno Quites Machado Filho
Related topics:
CompilersLinux
Related products:
Red Hat Enterprise Linux

    LLD is a linker developed by the LLVM project. It is a drop-in replacement for the system linker and aims to consume less resources than them.

    LLD provides production-quality support for the following architectures:

    • AArch64 and ARM
    • LoongArch
    • MIPS
    • PowerPC and PowerPC64
    • RISC-V
    • x86-32 and x86-64

    Despite this list, there is still one architecture supported by Fedora that was missing: s390x. This absence impacts how Fedora packages are built on s390x, either by prohibiting packages that require LLD or by requiring that the s390x package is linked with a different linker than other architectures. This difference is known to increase the maintenance burden because different linkers can behave differently.

    The support for s390x was added to LLD 18.1. In this article, we explore the work involved in order to get the support for s390x upstream and all the tests that were implemented and executed.

    The port

    Porting LLD to s390x consists of implementing the open source ELF Application Binary Interface - s390x Supplement in LLD.

    Adding support for a new architecture to LLD may benefit from previous work: LLVM already supported s390x and LLD already supported ELF files. That allows for the new s390x code in LLD to reuse both these implementations, reducing the development time.

    The code implementing it has less than 700 lines. An important part of this code implements symbol relocation. More specifically, this code implements all the relocation types listed in section 2.4 of the ELF Application Binary Interface - s390x Supplement.

    Functional testing

    More than a half of the lines in the commit that adds support for s390x to LLD are related to the functional testing of the linker itself.

    The 23 new tests evaluate if all the new implemented features are behaving as expected. They will help to identify regressions in new changes to LLD. For example, the test lld/test/ELF/systez-pie.s verifies if LLD can generate Position Independent Executables by parsing the ELF header, program headers, and the dynamic section looking for the expected values.

    Sanity checking Fedora packages

    After the implementation is complete, one question remains: is LLD ready to be used in order to link s390x software? The best way to answer this question is by linking software using LLD.

    The Fedora community provides all the infrastructure needed to run this kind of test:

    • copr provides the s390x servers that we can use to rebuild RPM packages and run their tests.
    • mass-prebuild provides a way to create mass rebuilds in order to assess the stability of a given change.

    First, we configured mass-prebuild in order to build LLD and set it as the default linker for our project in copr. We also listed more than 1,300 RPM packages. Mass-prebuild has a mechanism to identify packages with issues that should be ignored. By having a large number of packages, we are able to test a large group even if part of the packages are discarded.

    After completing the mass rebuild, we investigated all the failures. Interestingly, this exposed issues in other projects that had never been built with a different linker on Linux on s390x. One example of these changes is a fix to Valgrind’s helgrind/tests/tc11_XCHG. LLD was able to detect and report a programming error that was generating a branch to an unexpected address.

    Another source of valuable tests came from the ClangBuiltLinux project that build the Linux kernel using the tools from the LLVM project.

    This work helped the Linux kernel community to identify and fix 5 issues upstream that blocked the usage of LLD when linking the Linux kernel for s390x:

    • ld.lld: error: unknown argument ‘-fPIC’
    • “writable SHF_MERGE section is not supported” lld error in s390 __bug_table sections
    • ld.lld: error: relocation R_390_64 cannot be used against local symbol; recompile with -fPIC
    • s390 “ld.lld: error: section … virtual address range overlaps with …”
    • ld.lld: error: .btf.vmlinux.bin.o: unknown file type

    Conclusions

    The availability of LLD on all architectures supported by Fedora removes one of the barriers that caused Fedora to have fewer packages available on s390x. It helps to reduce the maintenance burden by allowing packages to use the same linker on all architectures.

    It also helps to give a choice to s390x developers by providing and alternative linker that may reduce link time of large projects.

    References

    • LLD project
    • ELF Application Binary Interface - s390x Supplement
    • Pull request adding support for s390x
    • ClangBuiltLinux project
    • Find errors in packages through mass builds

    Related Posts

    • Getting started with llvm-toolset

    • Find errors in packages through mass builds

    • mass-prebuild: An open source journey of improvement and growth

    • How to install GCC 8 and Clang/LLVM 6 on Red Hat Enterprise Linux 7

    • Go for C++ developers: A beginner's guide

    • Improvements to static analysis in the GCC 14 compiler

    Recent Posts

    • Protect data offloaded to GPU-accelerated environments with OpenShift sandboxed containers

    • Case study: Measuring energy efficiency on the x64 platform

    • How to prevent AI inference stack silent failures

    • Preventing GPU waste: A guide to JIT checkpointing with Kubeflow Trainer on OpenShift AI

    • How to manage TLS certificates used by OpenShift GitOps operator

    What’s up next?

    This cheat sheet helps you get familiar with over 30 basic Linux command-line executables frequently used by developers.

    Get the cheat sheet
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.