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
ed3b263e
Commit
ed3b263e
authored
10 years ago
by
jdh8d
Browse files
Options
Downloads
Patches
Plain Diff
No commit message
No commit message
parent
0288532e
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
+11
-4
11 additions, 4 deletions
scfi_instr.cpp
with
11 additions
and
4 deletions
scfi_instr.cpp
+
11
−
4
View file @
ed3b263e
...
...
@@ -234,10 +234,12 @@ unsigned int SCFI_Instrument::GetNonceSize(Instruction_t* insn)
bool
SCFI_Instrument
::
mark_targets
()
{
int
targets
=
0
;
for
(
InstructionSet_t
::
iterator
it
=
firp
->
GetInstructions
().
begin
();
it
!=
firp
->
GetInstructions
().
end
();
++
it
)
{
targets
++
;
Instruction_t
*
insn
=*
it
;
if
(
insn
->
GetIndirectBranchTargetAddress
())
{
...
...
@@ -250,12 +252,13 @@ bool SCFI_Instrument::mark_targets()
reloc
->
SetType
(
type
);
}
}
cout
<<
"#ATTRIBUTE targets_found="
<<
std
::
dec
<<
targets
<<
endl
;
return
true
;
}
void
SCFI_Instrument
::
AddReturnCFI
(
Instruction_t
*
insn
)
{
string
reg
=
"
r
cx"
;
string
reg
=
"
e
cx"
;
string
decoration
=
""
;
int
nonce_size
=
GetNonceSize
(
insn
);
unsigned
int
nonce
=
GetNonce
(
insn
);
...
...
@@ -263,11 +266,11 @@ void SCFI_Instrument::AddReturnCFI(Instruction_t* insn)
// convert a return to:
// pop
r
cx
// pop
e
cx
// cmp <nonce size> PTR [rcx-<nonce size>], Nonce
// jne slow ; reloc such that strata/zipr can convert slow to new code
// ; to handle places where nonce's can't be placed.
// jmp
r
cx
// jmp
e
cx
switch
(
nonce_size
)
{
...
...
@@ -325,7 +328,9 @@ bool SCFI_Instrument::instrument_jumps()
break
;
}
}
int
cfi_checks
=
0
;
// second pass, insert checking. can't do this on pass one because
// we add IBs, which we'd later decide instrument
...
...
@@ -333,9 +338,11 @@ bool SCFI_Instrument::instrument_jumps()
it
!=
to_instrument
.
end
();
++
it
)
{
cfi_checks
++
;
Instruction_t
*
insn
=*
it
;
AddReturnCFI
(
insn
);
}
cout
<<
"#ATTRIBUTE cfi_checks="
<<
std
::
dec
<<
cfi_checks
<<
endl
;
return
true
;
}
...
...
@@ -343,7 +350,7 @@ bool SCFI_Instrument::instrument_jumps()
bool
SCFI_Instrument
::
execute
()
{
bool
success
=
fals
e
;
bool
success
=
tru
e
;
success
=
success
&&
mark_targets
();
success
=
success
&&
instrument_jumps
();
...
...
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