diff options
| author | jsmall-nvidia <jsmall@nvidia.com> | 2023-01-12 17:11:42 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-12 17:11:42 -0500 |
| commit | 63b874dab2df8950a37e0861d24f322e0ab9bfda (patch) | |
| tree | 3e453281432120a171099b2458fedebd146c4643 | |
| parent | a3ac6e71cbc922b7c941c45f23ee18a9fc274d1f (diff) | |
Fix issue around linking/obfuscation (#2588)
* #include an absolute path didn't work - because paths were taken to always be relative.
* Work around for some issue seen with a repro.
* Small improvement in doing IDifferentable check.
* Fix around obfuscation linkage.
| -rw-r--r-- | source/slang/slang-lower-to-ir.cpp | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/source/slang/slang-lower-to-ir.cpp b/source/slang/slang-lower-to-ir.cpp index 6803e1cb4..4618b6786 100644 --- a/source/slang/slang-lower-to-ir.cpp +++ b/source/slang/slang-lower-to-ir.cpp @@ -1162,14 +1162,23 @@ static void addLinkageDecoration( IRInst* inst, Decl* decl) { - String mangledName = getMangledName(context->astBuilder, decl); + const String mangledName = getMangledName(context->astBuilder, decl); - if (context->shared->m_obfuscateCode) - { - mangledName = getHashedName(mangledName.getUnownedSlice()); - } - - addLinkageDecoration(context, inst, decl, mangledName.getUnownedSlice()); + // Obfuscate the mangled names if necessary. + // + // Care is needed around stdlib as it is only compiled once and *without* obfuscation, + // so any linkage name to stdlib *shouldn't* have obfuscation applied to it. + if (context->shared->m_obfuscateCode && + !isFromStdLib(decl)) + { + const auto obfuscatedName = getHashedName(mangledName.getUnownedSlice()); + + addLinkageDecoration(context, inst, decl, obfuscatedName.getUnownedSlice()); + } + else + { + addLinkageDecoration(context, inst, decl, mangledName.getUnownedSlice()); + } } bool shouldDeclBeTreatedAsInterfaceRequirement(Decl* requirementDecl) @@ -6244,6 +6253,7 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> // TODO: This approach doesn't really make sense for generic `extension` conformances. auto mangledName = getMangledNameForConformanceWitness(context->astBuilder, subType, superType); + // A witness table may need to be generic, if the outer // declaration (either a type declaration or an `extension`) // is generic. @@ -6271,6 +6281,9 @@ struct DeclLoweringVisitor : DeclVisitor<DeclLoweringVisitor, LoweredValInfo> auto irSubType = lowerType(subContext, subType); irWitnessTable->setOperand(0, irSubType); + // TODO(JS): + // Should the mangled name take part in obfuscation if enabled? + addLinkageDecoration(context, irWitnessTable, inheritanceDecl, mangledName.getUnownedSlice()); // If the witness table is for a COM interface, always keep it alive. |
