llvm-project/lld/MachO
Jez Ng 811444d7a1 [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
2020-12-17 08:49:16 -05:00
..
Arch [lld-macho] Don't emit rebase opcodes for relocs in TLV sections 2020-12-15 15:58:26 -05:00
CMakeLists.txt [lld-macho] Add dependency to DebugInfoDWARF 2020-12-01 19:10:46 -08:00
Config.h [lld/mac] implement -compatibility_version, -current_version 2020-12-14 18:41:36 -05:00
Driver.cpp [lld-macho] Add support for weak references 2020-12-17 08:49:16 -05:00
Driver.h [lld-macho] Don't load dylibs more than once 2020-12-10 15:57:52 -08:00
DriverUtils.cpp [lld-macho] -weak_{library,framework} should always take priority 2020-12-15 15:58:26 -05:00
Dwarf.cpp [lld-macho] Don't attempt to emit rebase opcodes for debug sections 2020-12-10 15:57:51 -08:00
Dwarf.h [lld-macho] Emit STABS symbols for debugging, and drop debug sections 2020-12-01 15:05:20 -08:00
ExportTrie.cpp [lld-macho] Support absolute symbols 2020-09-25 11:28:35 -07:00
ExportTrie.h [lld-macho] Export trie addresses should be relative to the image base 2020-09-20 20:43:15 -07:00
InputFiles.cpp [lld-macho] Add support for weak references 2020-12-17 08:49:16 -05:00
InputFiles.h [lld/mac] fill in current and compatibility version for LC_LOAD_(WEAK_)DYLIB 2020-12-15 19:34:59 -05:00
InputSection.cpp [lld-macho][nfc] Move some methods from InputFile to ObjFile 2020-12-08 10:34:32 -08:00
InputSection.h [lld-macho][nfc] Move some methods from InputFile to ObjFile 2020-12-08 10:34:32 -08:00
LTO.cpp [lld-macho] Add support for -mcpu, -mattr, -code-model in LTO 2020-12-10 15:57:51 -08:00
LTO.h [lld-macho] Add very basic support for LTO 2020-11-10 12:19:28 -08:00
MachOStructs.h [lld-macho] Ensure reads from nlist_64 structs are aligned when necessary 2020-06-02 13:19:38 -07:00
MergedOutputSection.cpp [lld-macho] Handle alignment correctly when merging InputSections 2020-06-17 20:41:28 -07:00
MergedOutputSection.h [lld-macho] Refactor segment/section creation, sorting, and merging 2020-06-21 17:13:59 -07:00
ObjC.cpp [lld-macho] Implement -ObjC 2020-08-26 19:20:55 -07:00
ObjC.h [lld-macho] Implement -ObjC 2020-08-26 19:20:55 -07:00
Options.td [lld-macho] Support -sub_umbrella 2020-12-15 15:58:26 -05:00
OutputSection.cpp [lld-macho] Refactor segment/section creation, sorting, and merging 2020-06-21 17:13:59 -07:00
OutputSection.h [lld-macho] Emit indirect symbol table 2020-09-23 19:26:40 -07:00
OutputSegment.cpp [lld-macho][easy] Fix segment max protection 2020-11-10 12:19:28 -08:00
OutputSegment.h [lld-macho] Emit STABS symbols for debugging, and drop debug sections 2020-12-01 15:05:20 -08:00
SymbolTable.cpp [lld-macho] Add support for weak references 2020-12-17 08:49:16 -05:00
SymbolTable.h [lld-macho] Add support for weak references 2020-12-17 08:49:16 -05:00
Symbols.cpp [lld/mac] Fix issues around thin archives 2020-12-01 18:48:29 -05:00
Symbols.h [lld-macho] Add support for weak references 2020-12-17 08:49:16 -05:00
SyntheticSections.cpp [lld-macho] Add support for weak references 2020-12-17 08:49:16 -05:00
SyntheticSections.h fix typos to cycle bots 2020-12-01 20:27:33 -05:00
Target.cpp Reland D75382 "[lld] Initial commit for new Mach-O backend" 2020-04-02 12:03:43 -07:00
Target.h [lld-macho] Implement weak binding for branch relocations 2020-08-27 17:44:15 -07:00
UnwindInfoSection.cpp fix typos to cycle bots 2020-12-01 20:27:33 -05:00
UnwindInfoSection.h [lld-macho] create __TEXT,__unwind_info from __LD,__compact_unwind 2020-09-18 22:01:03 -07:00
Writer.cpp [lld/mac] fill in current and compatibility version for LC_LOAD_(WEAK_)DYLIB 2020-12-15 19:34:59 -05:00
Writer.h [lld-macho] Extend SyntheticSections to cover all segment load commands 2020-04-27 12:58:12 -07:00