[lld-macho] Support __dso_handle for C++
authorJez Ng <jezng@fb.com>
Thu, 30 Jul 2020 21:28:41 +0000 (14:28 -0700)
committerJez Ng <jezng@fb.com>
Thu, 30 Jul 2020 21:28:41 +0000 (14:28 -0700)
commit3587de22819869a2925994d8bd75fa1386464660
tree416185b281a120a380e09f85d2c47970f4ab6ca0
parent9ebeac678855a1bc2492a9630f0300518e2755dc
[lld-macho] Support __dso_handle for C++

The C++ ABI requires dylibs to pass a pointer to __cxa_atexit which does
e.g. cleanup of static global variables. The C++ spec says that the pointer
can point to any address in one of the dylib's segments, but in practice
ld64 seems to set it to point to the header, so that's what's implemented
here.

Reviewed By: #lld-macho, smeenai

Differential Revision: https://reviews.llvm.org/D83603
lld/MachO/Driver.cpp
lld/MachO/SymbolTable.cpp
lld/MachO/SymbolTable.h
lld/MachO/Symbols.cpp
lld/MachO/Symbols.h
lld/MachO/SyntheticSections.h
lld/MachO/Writer.cpp
lld/test/MachO/dso-handle.s [new file with mode: 0644]
lld/test/MachO/invalid/dso-handle-duplicate.s [new file with mode: 0644]