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
96273d18
Commit
96273d18
authored
6 years ago
by
Jason Hiser
Browse files
Options
Downloads
Patches
Plain Diff
updates for more conservative cfg building
Former-commit-id: 86f0174abb0a114edc93a09493ab9523a8bce3da
parent
15572995
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
libIRDB-cfg/src/BasicBlock.cpp
+21
-11
21 additions, 11 deletions
libIRDB-cfg/src/BasicBlock.cpp
libIRDB-cfg/src/CFG.cpp
+1
-7
1 addition, 7 deletions
libIRDB-cfg/src/CFG.cpp
with
22 additions
and
18 deletions
libIRDB-cfg/src/BasicBlock.cpp
+
21
−
11
View file @
96273d18
...
...
@@ -78,6 +78,8 @@ void BasicBlock_t::BuildBlock
/* loop through the instructions for this block */
while
(
insn
)
{
const
auto
d
=
DecodedInstruction_t
::
factory
(
insn
);
/* insert this instruction */
instructions
.
push_back
(
insn
);
...
...
@@ -85,12 +87,13 @@ void BasicBlock_t::BuildBlock
auto
ft_insn
=
insn
->
getFallthrough
();
/* determine if there's a target block */
BasicBlock_t
*
target_block
=
NULL
;
if
(
target_insn
&&
is_in_container
(
insn2block_map
,
target_insn
))
BasicBlock_t
*
target_block
=
nullptr
;
const
auto
include_target
=
(
!
d
->
isCall
());
if
(
include_target
&&
target_insn
&&
is_in_container
(
insn2block_map
,
target_insn
))
target_block
=
find_map_object
(
insn2block_map
,
target_insn
);
/* determine if there's a ft block */
BasicBlock_t
*
ft_block
=
NULL
;
BasicBlock_t
*
ft_block
=
nullptr
;
if
(
ft_insn
&&
is_in_container
(
insn2block_map
,
ft_insn
))
ft_block
=
find_map_object
(
insn2block_map
,
ft_insn
);
...
...
@@ -108,14 +111,15 @@ void BasicBlock_t::BuildBlock
}
// handle fixed-call fallthroughs.
for_each
(
ALLOF
(
insn
->
getRelocations
()),
[
this
,
&
insn2block_map
](
IRDB_SDK
::
Relocation_t
*
reloc
)
// for_each(ALLOF(insn->getRelocations()), [this,&insn2block_map](IRDB_SDK::Relocation_t* reloc)
for
(
auto
reloc
:
insn
->
getRelocations
())
{
// and has a reloc that's a pcrel with a WRT object
// possible for a call to have a null fallthrouth (and consequently null WRT)
// becauase the call may be the last insn in a section, etc.
if
(
reloc
->
getType
()
==
string
(
"fix_call_fallthrough"
)
&&
reloc
->
getWRT
()
!=
NULL
)
if
(
reloc
->
getType
()
==
string
(
"fix_call_fallthrough"
)
&&
reloc
->
getWRT
()
!=
nullptr
)
{
assert
(
reloc
->
getWRT
()
!=
NULL
);
assert
(
reloc
->
getWRT
()
!=
nullptr
);
auto
fix_call_fallthrough_insn
=
dynamic_cast
<
Instruction_t
*>
(
reloc
->
getWRT
());
assert
(
fix_call_fallthrough_insn
);
...
...
@@ -129,7 +133,7 @@ void BasicBlock_t::BuildBlock
is_exit_block
=
false
;
}
}
)
;
};
/* if there's a fallthrough block, insert it into the appropriate sets */
...
...
@@ -156,13 +160,19 @@ void BasicBlock_t::BuildBlock
insn
=
ft_insn
;
}
// deal with IB targets for the end of the block
insn
=
instructions
[
instructions
.
size
()
-
1
];
// get last instruction.
assert
(
insn
);
if
(
insn
->
getIBTargets
())
const
auto
icfs
=
insn
->
getIBTargets
();
const
auto
d
=
DecodedInstruction_t
::
factory
(
insn
);
const
auto
include_icfs
=
(
d
->
isReturn
()
||
d
->
isCall
()
)
;
if
(
icfs
!=
nullptr
&&
include_icfs
)
{
for
_each
(
ALLOF
(
*
insn
->
getIBTargets
()),
[
this
,
&
insn2block_map
,
func
](
IRDB_SDK
::
Instruction_t
*
target
)
for
(
const
auto
target
:
*
icfs
)
{
if
(
is_in_container
(
insn2block_map
,
target
)
&&
target
!=
func
->
getEntryPoint
())
// don't link calls to the entry block.
{
...
...
@@ -170,7 +180,7 @@ void BasicBlock_t::BuildBlock
target_block
->
GetPredecessors
().
insert
(
this
);
successors
.
insert
(
target_block
);
}
}
)
;
};
}
}
...
...
@@ -222,7 +232,7 @@ IRDB_SDK::Instruction_t* BasicBlock_t::getBranchInstruction() const
{
if
(
!
endsInBranch
())
return
NULL
;
return
nullptr
;
auto
branch
=
instructions
[
instructions
.
size
()
-
1
];
return
branch
;
...
...
This diff is collapsed.
Click to expand it.
libIRDB-cfg/src/CFG.cpp
+
1
−
7
View file @
96273d18
...
...
@@ -72,14 +72,8 @@ static InstructionSet_t FindBlockStarts(IRDB_SDK::Function_t* func)
/* for each instruction, decide if it's a block start based on whether or not
* it can be indirectly branched to. Also mark direct targets as block starts.
*/
for
(
auto
it
=
func
->
getInstructions
().
begin
();
it
!=
func
->
getInstructions
().
end
();
++
it
)
for
(
auto
insn
:
func
->
getInstructions
())
{
/* Get the instruction */
auto
insn
=*
it
;
/* If this instruction might be an indirect branch target, then mark it as a block start */
if
(
insn
->
getIndirectBranchTargetAddress
())
{
...
...
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