llvm-capstone/lld/ELF
modimo 272bd6f9cc [WPD][LLD] Add option to validate RTTI is enabled on all native types and prevent devirtualization on types with native RTTI
Discussion about this approach: https://discourse.llvm.org/t/rfc-safer-whole-program-class-hierarchy-analysis/65144/18

When enabling WPD in an environment where native binaries are present, types we want to optimize can be derived from inside these native files and devirtualizing them can lead to correctness issues. RTTI can be used as a way to determine all such types in native files and exclude them from WPD providing a safe checked way to enable WPD.

The approach is:
1. In the linker, identify if RTTI is available for all native types. If not, under `--lto-validate-all-vtables-have-type-infos` `--lto-whole-program-visibility` is automatically disabled. This is done by examining all .symtab symbols in object files and .dynsym symbols in DSOs for vtable (_ZTV) and typeinfo (_ZTI) symbols and ensuring there's always a match for every vtable symbol.
2. During thinlink, if `--lto-validate-all-vtables-have-type-infos` is set and RTTI is available for all native types, identify all typename (_ZTS) symbols via their corresponding typeinfo (_ZTI) symbols that are used natively or outside of our summary and exclude them from WPD.

Testing:
ninja check-all
large Meta service that uses boost, glog and libstdc++.so runs successfully with WPD via --lto-whole-program-visibility. Previously, native types in boost caused incorrect devirtualization that led to crashes.

Reviewed By: MaskRay, tejohnson

Differential Revision: https://reviews.llvm.org/D155659
2023-09-18 15:51:49 -07:00
..
Arch [ELF] Implement getImplicitAddend and enable checkDynamicRelocsDefault for Hexagon 2023-09-15 23:10:17 -07:00
AArch64ErrataFix.cpp [llvm] Add missing StringExtras.h includes 2023-06-25 15:42:22 +01:00
AArch64ErrataFix.h [lld/elf] Use C++17 nested namespace syntax in most places 2022-08-10 16:47:30 -04:00
ARMErrataFix.cpp [lld] StringRef::{starts,ends}with => {starts,ends}_with. NFC 2023-06-05 14:36:19 -07:00
ARMErrataFix.h [lld/elf] Use C++17 nested namespace syntax in most places 2022-08-10 16:47:30 -04:00
CallGraphSort.cpp [ELF] CallGraphSort: replace vector<int> with unique_ptr<int[]>. NFC 2022-07-29 00:59:48 -07:00
CallGraphSort.h [lld/elf] Use C++17 nested namespace syntax in most places 2022-08-10 16:47:30 -04:00
CMakeLists.txt [lld][ELF] Support LoongArch 2023-07-25 17:06:07 +08:00
Config.h [WPD][LLD] Add option to validate RTTI is enabled on all native types and prevent devirtualization on types with native RTTI 2023-09-18 15:51:49 -07:00
Driver.cpp [WPD][LLD] Add option to validate RTTI is enabled on all native types and prevent devirtualization on types with native RTTI 2023-09-18 15:51:49 -07:00
Driver.h [llvm] Extract common OptTable bits into macros 2023-08-04 13:57:13 -07:00
DriverUtils.cpp [llvm] Extract common OptTable bits into macros 2023-08-04 13:57:13 -07:00
DWARF.cpp [DebugInfo] llvm::Optional => std::optional 2022-12-05 00:09:22 +00:00
DWARF.h [lld] Change Optional to std::optional 2022-11-27 17:25:34 -08:00
EhFrame.cpp [ELF] Change rawData to content() and data() to contentMaybeDecompress() 2022-11-20 22:43:22 +00:00
EhFrame.h [lld/elf] Use C++17 nested namespace syntax in most places 2022-08-10 16:47:30 -04:00
ICF.cpp [ELF] --icf: switch to xxh3_64bits 2023-07-18 17:57:31 -07:00
ICF.h [lld/elf] Use C++17 nested namespace syntax in most places 2022-08-10 16:47:30 -04:00
InputFiles.cpp [ELF] Make -t work with --format=binary 2023-09-16 00:41:23 -07:00
InputFiles.h [LLD][ELF] Cortex-M Security Extensions (CMSE) Support 2023-07-06 11:34:07 +01:00
InputSection.cpp [ELF][RISCV] Implement --emit-relocs with relaxation 2023-09-09 12:06:39 +02:00
InputSection.h [ELF][RISCV] Implement --emit-relocs with relaxation 2023-09-09 12:06:39 +02:00
LinkerScript.cpp [ELF] Remove a special case from ExprValue::getSectionOffset. NFC 2023-09-15 17:45:52 -07:00
LinkerScript.h [ELF] Align the end of PT_GNU_RELRO associated PT_LOAD to a common-page-size boundary (#66042) 2023-09-14 10:33:11 -07:00
LTO.cpp [WPD][LLD] Add option to validate RTTI is enabled on all native types and prevent devirtualization on types with native RTTI 2023-09-18 15:51:49 -07:00
LTO.h [lld/elf] Use C++17 nested namespace syntax in most places 2022-08-10 16:47:30 -04:00
MapFile.cpp [ELF] Make subsequent opens to auxiliary files append 2023-07-11 11:08:57 +00:00
MapFile.h [lld/elf] Use C++17 nested namespace syntax in most places 2022-08-10 16:47:30 -04:00
MarkLive.cpp [LLD][ELF] Cortex-M Security Extensions (CMSE) Support 2023-07-06 11:34:07 +01:00
MarkLive.h [lld/elf] Use C++17 nested namespace syntax in most places 2022-08-10 16:47:30 -04:00
Options.td [WPD][LLD] Add option to validate RTTI is enabled on all native types and prevent devirtualization on types with native RTTI 2023-09-18 15:51:49 -07:00
OutputSections.cpp [ELF] Implement getImplicitAddend and enable checkDynamicRelocsDefault for PPC32 2023-09-15 22:49:18 -07:00
OutputSections.h [ELF] Change most llvm::Optional to std::optional 2022-11-26 19:19:15 -08:00
README.md
Relocations.cpp [lld] Synthesize metadata for MTE globals 2023-07-31 17:07:42 +02:00
Relocations.h [lld] Synthesize metadata for MTE globals 2023-07-31 17:07:42 +02:00
ScriptLexer.cpp [ELF] Support operator ^ and ^= 2023-07-15 14:10:40 -07:00
ScriptLexer.h [lld/elf] Use C++17 nested namespace syntax in most places 2022-08-10 16:47:30 -04:00
ScriptParser.cpp [ELF] Correct a comment about ^=. NFC 2023-09-15 17:52:48 -07:00
ScriptParser.h [lld/elf] Use C++17 nested namespace syntax in most places 2022-08-10 16:47:30 -04:00
Symbols.cpp [ELF] Add -Bsymbolic-non-weak 2023-08-21 09:11:51 -07:00
Symbols.h [lld] Synthesize metadata for MTE globals 2023-07-31 17:07:42 +02:00
SymbolTable.cpp [ELF] Priorize the last catch-all pattern in version scripts 2023-09-09 23:47:01 -07:00
SymbolTable.h [LLD][ELF] Cortex-M Security Extensions (CMSE) Support 2023-07-06 11:34:07 +01:00
SyntheticSections.cpp [ELF] Align the end of PT_GNU_RELRO associated PT_LOAD to a common-page-size boundary (#66042) 2023-09-14 10:33:11 -07:00
SyntheticSections.h [ELF] Align the end of PT_GNU_RELRO associated PT_LOAD to a common-page-size boundary (#66042) 2023-09-14 10:33:11 -07:00
Target.cpp [lld][ELF] Support LoongArch 2023-07-25 17:06:07 +08:00
Target.h [PowerPC][lld] Account for additional X-Forms -> D-Form/DS-Forms load/stores when relaxing initial-exec to local-exec 2023-08-31 08:45:10 -05:00
Thunks.cpp [lld] Synthesize metadata for MTE globals 2023-07-31 17:07:42 +02:00
Thunks.h [ELF][PPC64] Actually implement --no-power10-stubs 2023-02-27 16:19:13 -08:00
Writer.cpp [ELF] Align the end of PT_GNU_RELRO associated PT_LOAD to a common-page-size boundary (#66042) 2023-09-14 10:33:11 -07:00
Writer.h [lld] Synthesize metadata for MTE globals 2023-07-31 17:07:42 +02:00

See docs/NewLLD.rst