[PATCH] D97641: [lld/mac] Add support for -flat_namespace

Nico Weber via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 28 12:27:44 PST 2021


thakis created this revision.
thakis added a reviewer: lld-macho.
Herald added a subscriber: dang.
Herald added a reviewer: int3.
Herald added a project: lld-macho.
thakis requested review of this revision.

-flat_namespace makes lld emit binaries that use name lookup that's more in
line with other POSIX systems: Instead of looking up symbols as (dylib,name)
pairs by dyld, they're instead looked up just by name.

-flat_namespace has three effects:

1. MH_TWOLEVEL and MH_NNOUNDEFS are no longer set in the Mach-O header
2. All symbols use BIND_SPECIAL_DYLIB_FLAT_LOOKUP as ordinal
3. When a dylib is added to the link, its dependent dylibs are also added, so that lld can verify that no undefined symbols remain at the end of a link with -flat_namespace. These transitive dylibs are added for symbol resolution, but they are not emitted in LC_LOAD_COMMANDs.

-undefined with -flat_namespace still isn't implemented. Before this change,
it was impossible to hit that combination because -flat_namespace caused a
diagnostic. Now that it no longer does, emit a dedicated temporary diagnostic
when both flags are used.


https://reviews.llvm.org/D97641

Files:
  lld/MachO/Driver.cpp
  lld/MachO/InputFiles.cpp
  lld/MachO/Options.td
  lld/MachO/SymbolTable.cpp
  lld/MachO/SyntheticSections.cpp
  lld/test/MachO/flat-namespace.s
  lld/test/MachO/header.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97641.326992.patch
Type: text/x-patch
Size: 8960 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210228/233fc441/attachment.bin>


More information about the llvm-commits mailing list