Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CFI
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
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
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
CFI
Commits
b23c4490
Commit
b23c4490
authored
9 years ago
by
jdh8d
Browse files
Options
Downloads
Patches
Plain Diff
Fixed issue with 'ret 4' insn
parent
2ceb75a3
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
scfi_instr.cpp
+31
-1
31 additions, 1 deletion
scfi_instr.cpp
with
31 additions
and
1 deletion
scfi_instr.cpp
+
31
−
1
View file @
b23c4490
...
...
@@ -347,9 +347,39 @@ void SCFI_Instrument::AddReturnCFI(Instruction_t* insn)
if
(
firp
->
GetArchitectureBitWidth
()
==
64
)
reg
=
"rcx"
;
// 64-bit reg.
string
rspreg
=
"esp"
;
// 32-bit reg
if
(
firp
->
GetArchitectureBitWidth
()
==
64
)
rspreg
=
"rsp"
;
// 64-bit reg.
string
worddec
=
"dword"
;
// 32-bit reg
if
(
firp
->
GetArchitectureBitWidth
()
==
64
)
worddec
=
"qword"
;
// 64-bit reg.
DISASM
d
;
insn
->
Disassemble
(
d
);
if
(
d
.
Argument1
.
ArgType
!=
NO_ARGUMENT
)
{
unsigned
int
sp_adjust
=
d
.
Instruction
.
Immediat
-
firp
->
GetArchitectureBitWidth
()
/
8
;
cout
<<
"Found relateively rare ret_with_pop insn: "
<<
d
.
CompleteInstr
<<
endl
;
char
buf
[
30
];
sprintf
(
buf
,
"pop %s [%s+%d]"
,
worddec
.
c_str
(),
rspreg
.
c_str
(),
sp_adjust
);
Instruction_t
*
newafter
=
insertAssemblyBefore
(
firp
,
insn
,
buf
);
if
(
sp_adjust
>
0
)
{
sprintf
(
buf
,
"lea %s, [%s+%d]"
,
rspreg
.
c_str
(),
rspreg
.
c_str
(),
sp_adjust
);
Instruction_t
*
newinsn
=
insertAssemblyAfter
(
firp
,
insn
,
buf
);
}
// rewrite the "old" isntruction, as that's what insertAssemblyBefore returns
insn
=
newafter
;
}
#ifdef CGC
// insert the pop/checking code.
// Instruction_t* after=insertAssemblyBefore(firp,insn,string("pop ")+reg);
Instruction_t
*
after
=
insn
;
string
jmpBits
=
getJumpDataBits
();
...
...
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