[PATCH] D93369: [lld-macho] Add support for weak references

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 15 21:36:18 PST 2020


int3 created this revision.
int3 added a reviewer: lld-macho.
int3 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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 function symbol weakrefs
like regular ones for now.

Fixes PR48511.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93369

Files:
  lld/MachO/Driver.cpp
  lld/MachO/InputFiles.cpp
  lld/MachO/SymbolTable.cpp
  lld/MachO/SymbolTable.h
  lld/MachO/Symbols.h
  lld/MachO/SyntheticSections.cpp
  lld/test/MachO/symtab.s
  lld/test/MachO/weak-reference.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93369.312104.patch
Type: text/x-patch
Size: 16078 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201216/d3296a91/attachment.bin>


More information about the llvm-commits mailing list