[all-commits] [llvm/llvm-project] 5c1d16: Reland "[JITLink] Initial AArch32 backend"

Stefan Gränitz via All-commits all-commits at lists.llvm.org
Fri Mar 24 02:20:38 PDT 2023

  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5c1d160cd979dd6099f4266db600020a0cb4867a
  Author: Stefan Gränitz <stefan.graenitz at gmail.com>
  Date:   2023-03-24 (Fri, 24 Mar 2023)

  Changed paths:
    A llvm/include/llvm/ExecutionEngine/JITLink/ELF_aarch32.h
    M llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
    A llvm/include/llvm/ExecutionEngine/JITLink/aarch32.h
    M llvm/lib/ExecutionEngine/JITLink/CMakeLists.txt
    M llvm/lib/ExecutionEngine/JITLink/ELF.cpp
    M llvm/lib/ExecutionEngine/JITLink/ELFLinkGraphBuilder.h
    A llvm/lib/ExecutionEngine/JITLink/ELF_aarch32.cpp
    A llvm/lib/ExecutionEngine/JITLink/aarch32.cpp
    M llvm/lib/ExecutionEngine/Orc/ObjectLinkingLayer.cpp
    A llvm/test/ExecutionEngine/JITLink/AArch32/ELF_thumbv7_printf.s
    A llvm/test/ExecutionEngine/JITLink/AArch32/lit.local.cfg
    A llvm/unittests/ExecutionEngine/JITLink/AArch32Tests.cpp
    M llvm/unittests/ExecutionEngine/JITLink/CMakeLists.txt

  Log Message:
  Reland "[JITLink] Initial AArch32 backend"

This first version lays the foundations for AArch32 support in JITLink. ELFLinkGraphBuilder_aarch32 processes REL-type relocations and populates LinkGraphs from ELF object files for both big- and little-endian systems. The ArmCfg member controls subarchitecture-specific details throughout the linking process (i.e. it's passed to ELFJITLinker_aarch32).

Relocation types follow the ABI documentation's division into classes: Data (endian-sensitive), Arm (32-bit little-endian) and Thumb (2x 16-bit little-endian, "Thumb32" in the docs). The implementation of instruction encoding/decoding for relocation resolution is implemented symmetrically and is testable in isolation (see AArch32 category in JITLinkTests).

Callable Thumb functions are marked with a ThumbSymbol target-flag and stored in the LinkGraph with their real addresses. The thumb-bit is added back in when the owning JITDylib requests the address for such a symbol.

The StubsManager can generate (absolute) Thumb-state stubs for branch range extensions on v7+ targets. Proper GOT/PLT handling is not yet implemented.

This patch is based on the backend implementation in ez-clang and has just enough functionality to model the infrastructure and link a Thumb function `main()` that calls `printf()` to dump "Hello Arm!" on Armv7a. It was tested on Raspberry Pi with 32-bit Raspbian OS.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D144083

More information about the All-commits mailing list