[all-commits] [llvm/llvm-project] cd14e7: lld/AArch64: handle more relocation addends (#87328)

Ramkumar Ramachandra via All-commits all-commits at lists.llvm.org
Thu Apr 11 01:37:18 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: cd14e7132f18dccd5fc7ed5e60258460bc1352f8
      https://github.com/llvm/llvm-project/commit/cd14e7132f18dccd5fc7ed5e60258460bc1352f8
  Author: Ramkumar Ramachandra <ram.ramachandra at arm.com>
  Date:   2024-04-11 (Thu, 11 Apr 2024)

  Changed paths:
    M lld/ELF/Arch/AArch64.cpp
    M lld/test/ELF/aarch64-reloc-implicit-addend.test

  Log Message:
  -----------
  lld/AArch64: handle more relocation addends (#87328)

The function getImplicitAddend() is incomplete, as it is possible to
cook up object files with other relocation addends. Although using
llvm-mc or the clang integrated assembler does not produce such object
files, a proprietary assembler known as armasm can:

https://developer.arm.com/documentation/101754/0622/armasm-Legacy-Assembler-Reference

armasm is in a frozen state, but it is still actively used in a lot of
legacy codebases as the directives, macros and operators are very
different from the clang integrated assembler. This makes porting a lot
of legacy code from armasm syntax impractical for a lot of projects.
Some internal testing of projects using open-source clang and lld fell
over at link time when legacy armasm objects were included in the link.

The goal of this patch is to enable people with legacy armasm objects to
be able to use lld as the linker. Sadly armasm uses SHT_REL format
relocations for AArch64 rather than SHT_RELA, which causes lld to reject
the objects. As a frozen project we know the small number of relocations
that the assembler officially supports and won't include (outside the
equivalent of the .reloc directive which I think we can rule out of
scope as that is not commonly used).

The benefit to lld is that it will ease migration from a proprietary to
an open-source toolchain. The drawback is the implementation of a small
number of SHT_REL relocations. Although this patch doesn't aim to
comprehensively cover all possible relocation addends, it does extend
lld to work with the relocation addends that armasm produces, using the
canonical aaelf64 document as a reference:

  https://github.com/ARM-software/abi-aa/blob/main/aaelf64/aaelf64.rst



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list