[all-commits] [llvm/llvm-project] dc8bee: [lld-macho] Check address ranges when applying rel...

Jez Ng via All-commits all-commits at lists.llvm.org
Fri Mar 12 14:26:55 PST 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: dc8bee92658e4ac2314aa2f59123078d49463219
      https://github.com/llvm/llvm-project/commit/dc8bee92658e4ac2314aa2f59123078d49463219
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-03-12 (Fri, 12 Mar 2021)

  Changed paths:
    M lld/MachO/Arch/ARM64.cpp
    M lld/MachO/Arch/X86_64.cpp
    M lld/MachO/InputFiles.cpp
    M lld/MachO/Relocations.cpp
    M lld/MachO/Relocations.h
    M lld/MachO/Target.h
    A lld/test/MachO/invalid/range-check.s

  Log Message:
  -----------
  [lld-macho] Check address ranges when applying relocations

This diff required fixing `getEmbeddedAddend` to apply sign
extension to 32-bit values. We were previously passing around wrong
64-bit addend values that became "right" after being truncated back to
32-bit.

I've also made `getEmbeddedAddend` return a signed int, which is similar
to what LLD-ELF does for its `getImplicitAddend`.

`reportRangeError`, `checkUInt`, and `checkInt` are counterparts of similar
functions in LLD-ELF.

Reviewed By: #lld-macho, thakis

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


  Commit: d8283d9ddcc5e9ffda7e72ae122df279b2c5ee17
      https://github.com/llvm/llvm-project/commit/d8283d9ddcc5e9ffda7e72ae122df279b2c5ee17
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-03-12 (Fri, 12 Mar 2021)

  Changed paths:
    M lld/MachO/Driver.cpp
    M lld/MachO/SymbolTable.cpp
    M lld/MachO/SymbolTable.h
    M lld/MachO/Symbols.cpp
    M lld/MachO/Symbols.h
    M lld/MachO/SyntheticSections.cpp
    M lld/MachO/SyntheticSections.h
    M lld/test/MachO/dso-handle.s
    M lld/test/MachO/invalid/dso-handle-duplicate.s

  Log Message:
  -----------
  [lld-macho][nfc] Give every SyntheticSection a fake InputSection

Previously, it was difficult to write code that handled both synthetic
and regular sections generically. We solve this problem by creating a
fake InputSection at the start of every SyntheticSection.

This refactor allows us to handle DSOHandle like a regular Defined
symbol (since Defined symbols must be attached to an InputSection), and
paves the way for supporting `__mh_*header` symbols. Additionally, it
simplifies our binding/rebase code.

I did have to extend Defined a little -- it now has a `linkerInternal`
flag, to indicate that `___dso_handle` should not be in the final symbol
table.

I've also added some additional testing for `___dso_handle`.

Reviewed By: #lld-macho, oontvoo

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


  Commit: 38a6374564a5fbdca0643fce8ee224c689188640
      https://github.com/llvm/llvm-project/commit/38a6374564a5fbdca0643fce8ee224c689188640
  Author: Jez Ng <jezng at fb.com>
  Date:   2021-03-12 (Fri, 12 Mar 2021)

  Changed paths:
    M lld/MachO/Driver.cpp
    M lld/test/MachO/Inputs/iPhoneSimulator.sdk/usr/lib/libSystem.tbd
    M lld/test/MachO/adhoc-codesign.s

  Log Message:
  -----------
  [lld-macho] Only codesign by default on arm64 macOS

instead of doing it on all arm64 platforms.

Reviewed By: #lld-macho, gkm

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


Compare: https://github.com/llvm/llvm-project/compare/7b5ab956b1ff...38a6374564a5


More information about the All-commits mailing list