[all-commits] [llvm/llvm-project] 811444: [lld-macho] Add support for weak references

Jez Ng via All-commits all-commits at lists.llvm.org
Thu Dec 17 05:53:42 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 811444d7a173e696f975f8d41626f6809439f726
      https://github.com/llvm/llvm-project/commit/811444d7a173e696f975f8d41626f6809439f726
  Author: Jez Ng <jezng at fb.com>
  Date:   2020-12-17 (Thu, 17 Dec 2020)

  Changed paths:
    M lld/MachO/Driver.cpp
    M lld/MachO/InputFiles.cpp
    M lld/MachO/SymbolTable.cpp
    M lld/MachO/SymbolTable.h
    M lld/MachO/Symbols.h
    M lld/MachO/SyntheticSections.cpp
    M lld/test/MachO/symtab.s
    A lld/test/MachO/weak-reference.s

  Log Message:
  -----------
  [lld-macho] Add support for weak references

Weak references need not necessarily be satisfied at runtime (but they must
still be satisfied at link time). So symbol resolution still works as per usual,
but we now pass around a flag -- ultimately emitting it in the bind table -- to
indicate if a given dylib symbol is a weak reference.

ld64's behavior for symbols that have both weak and strong references is
a bit bizarre. For non-function symbols, it will emit a weak import. For
function symbols (those referenced by BRANCH relocs), it will emit a
regular import. I'm not sure what value there is in that behavior, and
since emulating it will make our implementation more complex, I've
decided to treat regular weakrefs like function symbol ones for now.

Fixes PR48511.

Reviewed By: #lld-macho, thakis

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


  Commit: 4c8276cdc120c24410dcd62a9986f04e7327fc2f
      https://github.com/llvm/llvm-project/commit/4c8276cdc120c24410dcd62a9986f04e7327fc2f
  Author: Jez Ng <jezng at fb.com>
  Date:   2020-12-17 (Thu, 17 Dec 2020)

  Changed paths:
    M lld/MachO/InputFiles.cpp
    M lld/MachO/InputFiles.h
    M lld/MachO/Symbols.h
    M lld/MachO/Writer.cpp
    M lld/test/MachO/weak-import.s

  Log Message:
  -----------
  [lld-macho] Use LC_LOAD_WEAK_DYLIB for dylibs with only weakrefs

Note that dylibs without *any* refs will still be loaded in the usual
(strong) fashion.

Reviewed By: #lld-macho, thakis

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


Compare: https://github.com/llvm/llvm-project/compare/c5046ebdf6e4...4c8276cdc120


More information about the All-commits mailing list