[PATCH] D119294: [lld-macho] -flat_namespace for dylibs should make all externs interposable

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 8 15:00:41 PST 2022


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

All references to interposable symbols can be redirected at runtime to
point to a different symbol definition (with the same name). For
example, if both dylib A and B define symbol _foo, and we load A before
B at runtime, then all references to _foo within dylib B will point to
the definition in dylib A.

ld64 makes all extern symbols interposable when linking with
`-flat_namespace`.

TODO 1: Support `-interposable` and `-interposable_list`, which should
just be a matter of parsing those CLI flags and setting the
`Defined::interposable` bit.

TODO 2: Set Reloc::FinalDefinitionInLinkageUnit correctly with this info
(we are currently not setting it at all, so we're erring on the
conservative side, but we should help the LTO backend generate more
optimal code.)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119294

Files:
  lld/MachO/Arch/ARM.cpp
  lld/MachO/Arch/ARM64.cpp
  lld/MachO/Arch/ARM64Common.h
  lld/MachO/Arch/ARM64_32.cpp
  lld/MachO/Arch/X86_64.cpp
  lld/MachO/SymbolTable.cpp
  lld/MachO/Symbols.cpp
  lld/MachO/Symbols.h
  lld/MachO/SyntheticSections.cpp
  lld/MachO/SyntheticSections.h
  lld/MachO/Target.h
  lld/MachO/Writer.cpp
  lld/test/MachO/flat-namespace-dysyms.s
  lld/test/MachO/flat-namespace-interposable.s
  lld/test/MachO/flat-namespace.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D119294.406987.patch
Type: text/x-patch
Size: 22708 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220208/b47c3ab0/attachment.bin>


More information about the llvm-commits mailing list