-
Notifications
You must be signed in to change notification settings - Fork 185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix two GlobalsEncryption pass bugs #59
base: main
Are you sure you want to change the base?
Conversation
@@ -28,19 +28,25 @@ bool GlobalsEncryption::runOnModule(Module &M) { | |||
INIT_CONTEXT(M); | |||
vector<GlobalVariable *> GVs; | |||
for (GlobalVariable &GV : M.getGlobalList()) { | |||
// only process non llvm-generated IRs | |||
if(GV.getName().contains("llvm")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我们把 Module 内的所有 Globals 筛选出来的时候,没有对全局变量做特判,这会导致有一部分由 llvm 生成的全局变量(这里代称为 llvm-global)也放到列表中来。
其实本来这也没什么问题的,因为后续我们有语句去把这些无关的变量过滤掉。
但是,我们的 appendToGlobalCtors 函数会删除 llvm-global,再添加新的 llvm-global,这会导致之前 vector 中的 llvm-global 变成无意义指针,后续的 pass 在处理变量的时候会 crash 掉,所以我们一开始就不应该把这些变量筛选进来。
所以把有 llvm 字样的所有全局变量忽略掉就好了。
} | ||
if(GV->getValueType()->isArrayTy()){ // the value can be array | ||
ArrayType *ArrTy = dyn_cast<ArrayType>(GV->getValueType()); | ||
if(!ArrTy->getElementType()->isIntegerTy()){ // but the array must be integerty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我们对数组变量做筛选的时候,没有判断数组内元素是否为浮点,正好 IR 没办法拿 double、float 来做异或,所以遇到这种数,就需要跳过,不做处理。
如果后续有对浮点的加密方式,需要重新写相关逻辑。
Fix Pluto flat mode bugs
ignore intdata in GlobalsEncryption(bug)
Fix bugs: