Skip to content

Conversation

@serpilliere
Copy link
Contributor

No description provided.

@serpilliere
Copy link
Contributor Author

serpilliere commented Apr 11, 2018

Hi!
@mrphrazer, news for the SSA: It's really an key feature and we really want to include it in Miasm. As your PR is old (2 year ago!) I reworked it and rebased it on the current master. Old comments from the original PR have been taken in account as well.

We have used it (for example in constant propagation), and it really gives instesting results 😄
As I modified your commit, but keep your name in the commit, tell me if you are ok with this, because we are burning to release the next parts 😄

Thanks to you and Niko Schmidt for the job!

@mrphrazer
Copy link
Contributor

Hi!

We are happy to hear this :) Go for it!

@serpilliere
Copy link
Contributor Author

PR seems ready to me

@serpilliere
Copy link
Contributor Author

Rebase done

Handling of
- variable generation
- variable renaming
- conversion of an DiGraphIR block into SSA
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's now an "IRCFG" ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

def __init__(self, ircfg):
"""
Initialises generic class for SSA
:param ircfg: instance of DiGrpahIR
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same remark here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

self.ssa_to_location = {}

# Don't SSA architecture's instruction pointer
self.immutable_ids = set([self.ircfg.IRDst])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand, the architecture's instruction pointer (PC / RIP / ...) will be SSA. Is it wanted? If so, the comment is maybe misleading

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I reflected the comment

# Don't SSA architecture's instruction pointer
self.immutable_ids = set([self.ircfg.IRDst])

@classmethod
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could even be a staticmethod

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this code and used native expr function

return expr


class SSAPath(SSABlock):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is SSAPath inheriting from SSABlock and not from SSA?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because you inherit reassemble_expr. Understanding a path as a sequence of block, this makes sense. A similar function on CFG-level would work differently since it has to consider all the different branches/phi nodes.

@commial
Copy link
Contributor

commial commented Jul 6, 2018

Thanks for the PR and for the work on re-integration to the current codebase!
Apart the few tiny comments, the patch is OK for me

@serpilliere serpilliere force-pushed the ssa_transform branch 2 times, most recently from 4f80bfd to afb5d04 Compare July 9, 2018 07:16

def __init__(self, ircfg):
"""
Initialises SSA class for directed acyclic graphs
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A last question for @mrphrazer
The acyclic here seems strange to me here.
I think it's possible to have cylces in even in ssa form, passing through a phi operator.
Did I miss something here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, the implemention works as it is also for cycles. The comment is a relic from a project where I had to enforce acylcic graphs via loop unrolling.

mrphrazer and others added 2 commits July 9, 2018 12:31
@commial commial merged commit 17d48de into cea-sec:master Jul 9, 2018
@commial
Copy link
Contributor

commial commented Jul 9, 2018

Thanks again @mrphrazer for this contribution, and @serpilliere for refactoring it. We were using it internally for some time now, and it's quite a nice tool!

@serpilliere serpilliere deleted the ssa_transform branch July 9, 2018 11:02
w4kfu pushed a commit to w4kfu/miasm that referenced this pull request Jun 16, 2020
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

Successfully merging this pull request may close these issues.

3 participants