问题描述
对于逆向工程师而言,将图形调试器附加到OpenGL应用程序以提取着色器源代码很简单.据我了解,Vulkan则使用SPIR-V字节码,而不是将纯文本着色器传递给图形API.
It is straightforward for a reverse engineer to attach a graphics debugger to an OpenGL application to extract the shader source code. It is my understanding that Vulkan, on the other hand, uses SPIR-V bytecode, rather than passing plaintext shaders to the graphics API.
SPIR-V字节码会混淆着色器源,还是相当容易反编译?
Does SPIR-V bytecode obfuscate the shader source, or is it fairly easy to decompile?
推荐答案
有一个整个规范详细解释了每个SPIR-V操作码的行为.这有点混淆了.除此之外,还有更多.
There is an entire specification explaining, in explicit detail, the behavior of each and every SPIR-V opcode. That's kinda the opposite of obfuscation. But there's more to it than that.
SPIR-V尽管是汇编"的,但保留了大量有关源程序的信息.它包含结构定义,带有参数和返回类型的函数定义,循环和条件构造等.为SPIR-V编写反编译器并不困难.
SPIR-V, despite being "assembly", retains a rich amount of information about the source program. It contains structure definitions, function definitions with parameter and return types, looping and conditional constructs, etc. Writing a decompiler for SPIR-V is not at all difficult.
SPIR-V还可以选择包含注释各种SPIR-V定义的文本片段.这更像是编译为SPIR-V的环境的功能,但是输出SPIR-V可以包含变量名,结构名等.如果需要,可以轻松选择这些OpName装饰.
SPIR-V also can optionally contain fragments of text that annotate various SPIR-V definitions. This is more of a function of the environment that compiled to SPIR-V, but the output SPIR-V can contain variable names, structure names, and etc. These OpName decorations can all be easily culled if you wish.
但是,即使没有名称,所有重要的结构信息也都存在.因此,与原始GLSL相比,SPIR-V带来的安全性提升很小.
But even without names, all of the important structural information is there. So the security gains from SPIR-V compared to raw GLSL is rather minimal.
这篇关于SPIR-V字节码是否提供混淆功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!