Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Z
Zipr Toolchain
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open Source Software
Zipr Toolchain
Commits
f16010b4
Commit
f16010b4
authored
13 years ago
by
an7s
Browse files
Options
Downloads
Patches
Plain Diff
Modi
parent
e401161a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tools/transforms/integerbugtransform.cpp
+35
-16
35 additions, 16 deletions
tools/transforms/integerbugtransform.cpp
tools/transforms/p1transform.cpp
+1
-1
1 addition, 1 deletion
tools/transforms/p1transform.cpp
with
36 additions
and
17 deletions
tools/transforms/integerbugtransform.cpp
+
35
−
16
View file @
f16010b4
...
...
@@ -15,8 +15,8 @@ using namespace std;
// getAssembly is now part of the interface for an instruction -- reuse if needed
// accept white list
// move utility functions to instruction interface
// since we filter by functions, we should loop over functions first, then look at instrutions
//
//
// return available offset
//
...
...
@@ -91,21 +91,28 @@ static bool isAddSubNonEspInstruction32(Instruction_t *p_instruction)
DISASM
disasm
;
// look for "add ..." or "sub ..."
// look for "addl ..." or "subl ..."
p_instruction
->
Disassemble
(
disasm
);
fprintf
(
stderr
,
"INT DEBUG: inst: 0x%x [%s] [%s]
\n
"
,
p_instruction
->
GetAddress
(),
disasm
.
Instruction
.
Mnemonic
,
p_instruction
->
GetComment
().
c_str
());
// beaengine adds space at the end of the mnemonic string
if
(
strcasestr
(
disasm
.
Instruction
.
Mnemonic
,
"add "
))
if
(
strcasestr
(
disasm
.
Instruction
.
Mnemonic
,
"add "
)
||
strcasestr
(
disasm
.
Instruction
.
Mnemonic
,
"addl"
))
{
return
true
;
}
else
if
(
strcasestr
(
disasm
.
Instruction
.
Mnemonic
,
"sub "
))
else
if
(
strcasestr
(
disasm
.
Instruction
.
Mnemonic
,
"sub "
)
||
strcasestr
(
disasm
.
Instruction
.
Mnemonic
,
"subl"
))
{
/*
if (strcasestr(disasm.Argument1.ArgMnemonic,"esp") &&
(disasm.Argument2.ArgType & 0xFFFF0000 & (CONSTANT_TYPE | ABSOLUTE_)))
{
// optimization: filter out "sub esp, K"
return false;
}
*/
return
true
;
}
...
...
@@ -218,7 +225,7 @@ static void addOverflowCheck(VariantIR_t *p_virp, Instruction_t *p_instruction,
dataBits
.
resize
(
1
);
dataBits
[
0
]
=
0x58
;
poparg_i
->
SetDataBits
(
dataBits
);
poparg_i
->
SetComment
(
getAssembly
(
poparg_i
)
+
" -- with callback to "
+
p_detector
)
;
poparg_i
->
SetComment
(
getAssembly
(
poparg_i
)
+
" -- with callback to "
+
p_detector
+
" orig: "
+
p_instruction
->
GetComment
())
;
poparg_i
->
SetFallthrough
(
popa_i
);
poparg_i
->
SetIndirectBranchTargetAddress
(
poparg_a
);
poparg_i
->
SetCallback
(
p_detector
);
...
...
@@ -302,21 +309,32 @@ main(int argc, char* argv[])
assert
(
virp
&&
pidp
);
int
numMul
=
0
,
numAddSub
=
0
;
for
(
set
<
Instruction_t
*>::
const_iterator
it
=
virp
->
GetInstructions
().
begin
();
it
!=
virp
->
GetInstructions
().
end
();
++
it
)
for
(
set
<
Function_t
*>::
const_iterator
itf
=
virp
->
GetFunctions
().
begin
();
itf
!=
virp
->
GetFunctions
().
end
();
++
itf
)
{
Function_t
*
func
=*
itf
;
cerr
<<
"looking at function: "
<<
func
->
GetName
()
<<
endl
;
if
(
filteredFunctions
.
find
(
func
->
GetName
())
!=
filteredFunctions
.
end
())
{
Instruction_t
*
insn
=*
it
;
if
(
!
insn
->
GetFunction
())
continue
;
cerr
<<
"filtering function: "
<<
func
->
GetName
()
<<
endl
;
continue
;
}
if
(
filteredFunctions
.
find
(
insn
->
GetFunction
()
->
GetName
())
!=
filteredFunctions
.
end
())
{
continue
;
}
for
(
set
<
Instruction_t
*>::
const_iterator
it
=
func
->
GetInstructions
().
begin
();
it
!=
func
->
GetInstructions
().
end
();
++
it
)
{
Instruction_t
*
insn
=*
it
;
if
(
isMultiplyInstruction32
(
insn
))
{
...
...
@@ -338,6 +356,7 @@ main(int argc, char* argv[])
}
}
}
cout
<<
"Writing variant "
<<*
pidp
<<
" back to database."
<<
endl
;
virp
->
WriteToDB
();
...
...
This diff is collapsed.
Click to expand it.
tools/transforms/p1transform.cpp
+
1
−
1
View file @
f16010b4
...
...
@@ -329,7 +329,7 @@ int main(int argc, char **argv)
{
if
(
argc
!=
3
)
{
cerr
<<
"Usage:
[the executable]
<variantid> [file containing name of blacklisted functions]"
<<
endl
;
cerr
<<
"Usage:
p1transform.exe
<variantid> [file containing name of blacklisted functions]"
<<
endl
;
exit
(
-
1
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment