Skip to content
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

BogusControlFlow bug #165

Open
bluesadi opened this issue Jul 25, 2021 · 1 comment
Open

BogusControlFlow bug #165

bluesadi opened this issue Jul 25, 2021 · 1 comment

Comments

@bluesadi
Copy link

bluesadi commented Jul 25, 2021

In obfuscator/lib/Transforms/Obfuscation/BogusControlFlow.cpp:

// Split the block: first part with only the phi nodes and debug info and terminator
//                  created by splitBasicBlock. (-> No instruction)
//                  Second part with every instructions from the original block
// We do this way, so we don't have to adjust all the phi nodes, metadatas and so on
// for the first block. We have to let the phi nodes in the first part, because they
// actually are updated in the second part according to them.
BasicBlock::iterator i1 = basicBlock->begin();
if(basicBlock->getFirstNonPHIOrDbgOrLifetime())
 i1 = (BasicBlock::iterator)basicBlock->getFirstNonPHIOrDbgOrLifetime();

It really confuse me.
As far as I know, there is no constraint that a basic block can only have one phi node.
So we still have to adjust the phi nodes in the second part, or can we let all the phi nodes in the first part?

@v4kst1z
Copy link

v4kst1z commented Aug 14, 2021

In obfuscator/lib/Transforms/Obfuscation/BogusControlFlow.cpp:

// Split the block: first part with only the phi nodes and debug info and terminator
//                  created by splitBasicBlock. (-> No instruction)
//                  Second part with every instructions from the original block
// We do this way, so we don't have to adjust all the phi nodes, metadatas and so on
// for the first block. We have to let the phi nodes in the first part, because they
// actually are updated in the second part according to them.
BasicBlock::iterator i1 = basicBlock->begin();
if(basicBlock->getFirstNonPHIOrDbgOrLifetime())
 i1 = (BasicBlock::iterator)basicBlock->getFirstNonPHIOrDbgOrLifetime();

It really confuse me.
As far as I know, there is no constraint that a basic block can only have one phi node.
So we still have to adjust the phi nodes in the second part, or can we let all the phi nodes in the first part?

getFirstNonPHIOrDbgOrLifetime 函数得到的就是第一个不属于 Phi、Dbg 和 Lifetime 的指令,所有所有 phi 节点都在第一部分

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants