-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I DO NOT LIKE AT&T SYNTAX AT ALL
- Loading branch information
0 parents
commit a35e8f9
Showing
15 changed files
with
3,322 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
parser/as2cfg.y.go | ||
/as2cfg.out | ||
/y.output |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
as2cfg.out: parser/as2cfg.l.go parser/as2cfg.y.go virtualall | ||
go build -o as2cfg.out github.com/hidva/as2cfg/as2cfg | ||
|
||
parser/as2cfg.l.go: parser/as2cfg.l | ||
golex -o parser/as2cfg.l.go parser/as2cfg.l | ||
parser/as2cfg.y.go: parser/as2cfg.y | ||
goyacc -o parser/as2cfg.y.go parser/as2cfg.y | ||
|
||
.PHONY: virtualall | ||
virtualall: | ||
@echo "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
AS2CFG, a utility from converting the assembly code output by GDB disassembler to CFG(Control Flow Graph). | ||
|
||
Currently, the usage is very simple, just type: | ||
|
||
``` | ||
gdb --batch -ex 'disas MyAtoI' atoi.out | grep -F 0x | as2cfg | dot -Tsvg > atoi.cfg.svg | ||
``` | ||
|
||
`atoi.out` is compiled from: | ||
|
||
```c | ||
int MyAtoI(const char *input) { | ||
int res = 0; | ||
int sign = 1; | ||
|
||
while (*input == ' ' || *input == '\t') | ||
++input; | ||
|
||
if (*input == '-') { | ||
sign = -1; | ||
++input; | ||
} else if (*input == '+') { | ||
++input; | ||
} | ||
|
||
for (; *input != '\0'; ++input) { | ||
if (*input >= '0' && *input <= '9') { | ||
res = res * 10 + *input - '0'; | ||
} else { | ||
break; | ||
} | ||
} | ||
|
||
return sign * res; | ||
} | ||
``` | ||
And `atoi.cfg.svg` looks like: | ||
![atoi.cfg.svg](https://github.com/hidva/as2cfg/blob/master/atoi.cfg.svg) | ||
The operand in instruction is represented by its SSA name, it means that if two operands in the same block have the same SSA name, they are the same operand. | ||
And we will attempt to generate more meanful expression for edge constructed by Jcc(JE, JNE, etc.) instruction, such as that the expression for the edge constructed by the 'je(0x400590)' after 'cmp(dl_1,0x9)' is `dl_1 == 0x9` and `dl_1 != 0x9`, not just `ZF = 1` and `ZF = 0`. |
Oops, something went wrong.