diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2025-08-23 10:21:00 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-08-23 10:21:00 +0900 |
commit | 65d12622faa2a16f7e5d1fc6b101a670dbf26391 (patch) | |
tree | e6d01813a660d7e60f32082898d193faf6750986 /llvm/lib/Object/IRSymtab.cpp | |
parent | fd330dedcbb729bb0a77abec58162b2f5ec2136c (diff) | |
download | llvm-65d12622faa2a16f7e5d1fc6b101a670dbf26391.zip llvm-65d12622faa2a16f7e5d1fc6b101a670dbf26391.tar.gz llvm-65d12622faa2a16f7e5d1fc6b101a670dbf26391.tar.bz2 |
RuntimeLibcalls: Add entries for stackprotector globals (#154930)
Add entries for_stack_chk_guard, __ssp_canary_word, __security_cookie,
and __guard_local. As far as I can tell these are all just different
names for the same shaped functionality on different systems.
These aren't really functions, but special global variable names. They
should probably be treated the same way; all the same contexts that
need to know about emittable function names also need to know about
this. This avoids a special case check in IRSymtab.
This isn't a complete change, there's a lot more cleanup which
should be done. The stack protector configuration system is a
complete mess. There are multiple overlapping controls, used in
3 different places. Some of the target control implementations overlap
with conditions used in the emission points, and some use correlated
but not identical conditions in different contexts.
i.e. useLoadStackGuardNode, getIRStackGuard, getSSPStackGuardCheck and
insertSSPDeclarations are all used in inconsistent ways so I don't know
if I've tracked the intention of the system correctly.
The PowerPC test change is a bug fix on linux. Previously the manual
conditions were based around !isOSOpenBSD, which is not the condition
where __stack_chk_guard are used. Now getSDagStackGuard returns the
proper global reference, resulting in LOAD_STACK_GUARD getting a
MachineMemOperand which allows scheduling.
Diffstat (limited to 'llvm/lib/Object/IRSymtab.cpp')
-rw-r--r-- | llvm/lib/Object/IRSymtab.cpp | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/llvm/lib/Object/IRSymtab.cpp b/llvm/lib/Object/IRSymtab.cpp index 0043f02..a45b34e 100644 --- a/llvm/lib/Object/IRSymtab.cpp +++ b/llvm/lib/Object/IRSymtab.cpp @@ -46,18 +46,6 @@ static cl::opt<bool> DisableBitcodeVersionUpgrade( "disable-bitcode-version-upgrade", cl::Hidden, cl::desc("Disable automatic bitcode upgrade for version mismatch")); -static constexpr StringLiteral PreservedSymbols[] = { - // There are global variables, so put it here instead of in - // RuntimeLibcalls.td. - // TODO: Are there similar such variables? - "__ssp_canary_word", - "__stack_chk_guard", -}; - -static bool isPreservedGlobalVarName(StringRef Name) { - return PreservedSymbols[0] == Name || PreservedSymbols[1] == Name; -} - namespace { const char *getExpectedProducerName() { @@ -106,7 +94,7 @@ struct Builder { std::vector<storage::Str> DependentLibraries; - bool isPreservedLibFuncName(StringRef Name) { + bool isPreservedName(StringRef Name) { return Libcalls.getSupportedLibcallImpl(Name) != RTLIB::Unsupported; } @@ -281,8 +269,7 @@ Error Builder::addSymbol(const ModuleSymbolTable &Msymtab, StringRef GVName = GV->getName(); setStr(Sym.IRName, GVName); - if (Used.count(GV) || isPreservedLibFuncName(GVName) || - isPreservedGlobalVarName(GVName)) + if (Used.count(GV) || isPreservedName(GVName)) Sym.Flags |= 1 << storage::Symbol::FB_used; if (GV->isThreadLocal()) Sym.Flags |= 1 << storage::Symbol::FB_tls; |