Skip to main content
Redhat Developers  Logo
  • Products

    Platforms

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat AI
      Red Hat AI
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • View All Red Hat Products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat Developer Hub
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat OpenShift Local
    • Red Hat Developer Sandbox

      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Secure Development & Architectures

      • Security
      • Secure coding
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • Product Documentation
    • API Catalog
    • Legacy Documentation
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

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

Share:

    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

    • Cloud bursting with confidential containers on OpenShift

    • Reach native speed with MacOS llama.cpp container inference

    • A deep dive into Apache Kafka's KRaft protocol

    • Staying ahead of artificial intelligence threats

    • Strengthen privacy and security with encrypted DNS in RHEL

    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

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    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
    © 2025 Red Hat

    Red Hat legal and privacy links

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

    Report a website issue