[all-commits] [llvm/llvm-project] e5d780: [lld-macho] Use full input file name in invalid re...

Jez Ng via All-commits all-commits at lists.llvm.org
Tue Feb 23 19:02:59 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e5d780e049c275b628461c043fa5953ecd4f16e0
      https://github.com/llvm/llvm-project/commit/e5d780e049c275b628461c043fa5953ecd4f16e0
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-02-23 (Tue, 23 Feb 2021)

  Changed paths:
    M lld/MachO/InputFiles.cpp
    M lld/test/MachO/invalid/invalid-relocation-pcrel.yaml

  Log Message:
  -----------
  [lld-macho] Use full input file name in invalid relocation error message

Just something I noticed while debugging arm relocations...

Reviewed By: #lld-macho, thakis

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


  Commit: 5e851733c5b603bec962bb4c5cf9d5cc93d88175
      https://github.com/llvm/llvm-project/commit/5e851733c5b603bec962bb4c5cf9d5cc93d88175
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-02-23 (Tue, 23 Feb 2021)

  Changed paths:
    M lld/MachO/Arch/ARM64.cpp
    M lld/MachO/Arch/X86_64.cpp
    M lld/MachO/InputFiles.cpp
    M lld/MachO/InputSection.cpp
    M lld/MachO/Target.cpp
    M lld/MachO/Target.h
    M lld/MachO/Writer.cpp
    A lld/test/MachO/arm64-reloc-got-load.s
    A lld/test/MachO/arm64-reloc-pointer-to-got.s
    A lld/test/MachO/arm64-reloc-tlv-load.s

  Log Message:
  -----------
  [lld-macho] Fix semantics & add tests for ARM64 GOT/TLV relocs

I've adjusted the RelocAttrBits to better fit the semantics of
the relocations. In particular:

1. *_UNSIGNED relocations are no longer marked with the `TLV` bit, even
   though they can occur within TLV sections. Instead the `TLV` bit is
   reserved for relocations that can reference thread-local symbols, and
   *_UNSIGNED relocations have their own `UNSIGNED` bit. The previous
   implementation caused TLV and regular UNSIGNED semantics to be
   conflated, resulting in rebase opcodes being incorrectly emitted for TLV
   relocations.

2. I've added a new `POINTER` bit to denote non-relaxable GOT
   relocations. This distinction isn't important on x86 -- the GOT
   relocations there are either relaxable or non-relaxable loads -- but
   arm64 has `GOT_LOAD_PAGE21` which loads the page that the referent
   symbol is in (regardless of whether the symbol ends up in the GOT). This
   relocation must reference a GOT symbol (so must have the `GOT` bit set)
   but isn't itself relaxable (so must not have the `LOAD` bit). The
   `POINTER` bit is used for relocations that *must* reference a GOT
   slot.

3. A similar situation occurs for TLV relocations.

4. ld64 supports both a pcrel and an absolute version of
   ARM64_RELOC_POINTER_TO_GOT. But the semantics of the absolute version
   are pretty weird -- it results in the value of the GOT slot being
   written, rather than the address. (That means a reference to a
   dynamically-bound slot will result in zeroes being written.) The
   programs I've tried linking don't use this form of the relocation, so
   I've dropped our partial support for it by removing the relevant
   RelocAttrBits.

Reviewed By: alexshap

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


  Commit: 4752cdc9a20abb5fbb2a255011417b8a77e4c31e
      https://github.com/llvm/llvm-project/commit/4752cdc9a20abb5fbb2a255011417b8a77e4c31e
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-02-23 (Tue, 23 Feb 2021)

  Changed paths:
    M lld/MachO/InputFiles.cpp
    M lld/test/MachO/Inputs/MacOSX.sdk/usr/lib/libc++.tbd
    M lld/test/MachO/header.s
    A lld/test/MachO/invalid/Inputs/libincompatible.tbd
    A lld/test/MachO/invalid/incompatible-arch-tapi.s
    A lld/test/MachO/invalid/incompatible-arch.s

  Log Message:
  -----------
  [lld-macho] Check for arch compatibility when loading ObjFiles and TBDs

The silent failures had confused me a few times.

I haven't added a similar check for platform yet as we don't yet have logic to
infer the platform automatically, and so adding that check would require
updating dozens of test files.

Reviewed By: #lld-macho, thakis, alexshap

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


  Commit: 4a5e111aea7ac78190211a2549f8d0d53ee2f01d
      https://github.com/llvm/llvm-project/commit/4a5e111aea7ac78190211a2549f8d0d53ee2f01d
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-02-23 (Tue, 23 Feb 2021)

  Changed paths:
    M lld/MachO/UnwindInfoSection.cpp
    M lld/test/MachO/compact-unwind.s

  Log Message:
  -----------
  [lld-macho] Better deduplication of personality pointers

{D95809} introduced a mechanism for synthetic symbol creation of personality
pointers. When multiple section relocations referred to the same personality
pointer, it would deduplicate them. However, it neglected to consider that we
could have symbol relocations that also refer to the same personality pointer.
This diff fixes it.

In practice, this mix of relocations arises when there is a statically-linked
personality routine that is referenced from multiple object files. Within the
same object file, it will be referred to via section relocations, but
(obviously) other object files will refer to it via symbol relocations. Failing
to deduplicate these references resulted in us going over the
3-personality-pointer limit when linking some larger applications.

Fixes llvm.org/PR48389.

Reviewed By: #lld-macho, thakis, alexshap

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


Compare: https://github.com/llvm/llvm-project/compare/59f0e4627a5e...4a5e111aea7a


More information about the All-commits mailing list