[lld-macho][reland] Add support for N_INDR symbols
authorJez Ng <jezng@fb.com>
Fri, 16 Sep 2022 02:55:41 +0000 (22:55 -0400)
committerJez Ng <jezng@fb.com>
Fri, 16 Sep 2022 02:57:15 +0000 (22:57 -0400)
commitd515575714b60b2f2b01fcf3cfc6a380b44a6cee
treed7ee176621460c518d29712533ea0a9758e6dd10
parent83a0ac12f5f074fbaf773793de0e95572e073fa7
[lld-macho][reland] Add support for N_INDR symbols

This is similar to the `-alias` CLI option, but it gives finer-grained
control in that it allows the aliased symbols to be treated as private
externs.

While working on this, I realized that our `-alias` handling did not
cover the cases where the aliased symbol is a common or dylib symbol,
nor the case where we have an undefined that gets treated specially and
converted to a defined later on. My N_INDR handling neglects this too
for now; I've added checks and TODO messages for these.

`N_INDR` symbols cropped up as part of our attempt to link swift-stdlib.

Reviewed By: #lld-macho, thakis, thevinster

Differential Revision: https://reviews.llvm.org/D133825
lld/MachO/Driver.cpp
lld/MachO/InputFiles.cpp
lld/MachO/InputFiles.h
lld/MachO/SymbolTable.cpp
lld/MachO/SymbolTable.h
lld/MachO/Symbols.h
lld/docs/MachO/ld64-vs-lld.rst
lld/test/MachO/alias-option.s [moved from lld/test/MachO/aliases.s with 100% similarity]
lld/test/MachO/alias-symbols.s [new file with mode: 0644]