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
8186603a
Commit
8186603a
authored
9 years ago
by
an7s
Browse files
Options
Downloads
Patches
Plain Diff
parse ib provenance data from the STARS xref file
Former-commit-id: 9f4f704c3c1d759bb3c2cce9a6bee2e477132cc6
parent
436651af
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
xform/instruction_descriptor.cpp
+29
-0
29 additions, 0 deletions
xform/instruction_descriptor.cpp
xform/instruction_descriptor.h
+6
-2
6 additions, 2 deletions
xform/instruction_descriptor.h
xform/rewriter.cpp
+21
-5
21 additions, 5 deletions
xform/rewriter.cpp
with
56 additions
and
7 deletions
xform/instruction_descriptor.cpp
+
29
−
0
View file @
8186603a
...
...
@@ -36,6 +36,7 @@ wahoo::Instruction::Instruction()
m_isVisited
=
false
;
m_data
=
NULL
;
m_ib_complete
=
false
;
m_ib_provenance
=
IB_PROVENANCE_UNKNOWN
;
}
wahoo
::
Instruction
::
Instruction
(
app_iaddr_t
p_address
,
int
p_size
,
Function
*
p_func
)
...
...
@@ -50,6 +51,8 @@ wahoo::Instruction::Instruction(app_iaddr_t p_address, int p_size, Function* p_f
m_deallocSite
=
false
;
m_stackRef
=
false
;
m_data
=
NULL
;
m_ib_complete
=
false
;
m_ib_provenance
=
IB_PROVENANCE_UNKNOWN
;
}
wahoo
::
Instruction
::~
Instruction
()
...
...
@@ -84,3 +87,29 @@ void wahoo::Instruction::markVarStackRef()
{
m_varStackRef
=
true
;
}
void
wahoo
::
Instruction
::
setIbProvenance
(
char
*
p_provenance
)
{
std
::
string
provenance
(
p_provenance
);
if
(
provenance
==
"RETURNTARGET"
)
{
m_ib_provenance
=
IB_PROVENANCE_RETURN
;
}
else
if
(
provenance
==
"SWITCHTABLE"
)
{
m_ib_provenance
=
IB_PROVENANCE_SWITCH_TABLE
;
}
else
if
(
provenance
==
"INDIRCALL"
)
{
m_ib_provenance
=
IB_PROVENANCE_INDIRECT_CALL
;
}
else
if
(
provenance
==
"UNKNOWN"
)
{
m_ib_provenance
=
IB_PROVENANCE_UNKNOWN
;
}
else
{
m_ib_provenance
=
IB_PROVENANCE_UNKNOWN
;
}
}
This diff is collapsed.
Click to expand it.
xform/instruction_descriptor.h
+
6
−
2
View file @
8186603a
...
...
@@ -13,6 +13,8 @@ namespace wahoo {
class
Function
;
enum
IBProvenance
{
IB_PROVENANCE_UNKNOWN
,
IB_PROVENANCE_RETURN
,
IB_PROVENANCE_SWITCH_TABLE
,
IB_PROVENANCE_INDIRECT_CALL
};
class
Instruction
{
public:
Instruction
();
...
...
@@ -52,6 +54,9 @@ class Instruction {
const
std
::
set
<
Instruction
*>&
getIBTs
()
{
return
ibts
;
}
void
markIbComplete
(
bool
complete
=
true
)
{
m_ib_complete
=
complete
;
}
bool
isIbComplete
()
{
return
m_ib_complete
;
}
void
setIbProvenance
(
char
*
);
void
setIbProvenance
(
const
IBProvenance
p_provenance
)
{
m_ib_provenance
=
p_provenance
;
}
IBProvenance
getIbProvenance
()
const
{
return
m_ib_provenance
;
}
private
:
app_iaddr_t
m_address
;
...
...
@@ -59,7 +64,6 @@ class Instruction {
int
m_size
;
Function
*
m_function
;
string
m_asm
;
// unsigned char m_data[128];
unsigned
char
*
m_data
;
bool
m_allocSite
;
...
...
@@ -71,7 +75,7 @@ class Instruction {
std
::
set
<
Instruction
*>
ibts
;
bool
m_ib_complete
;
IBProvenance
m_ib_provenance
;
};
}
...
...
This diff is collapsed.
Click to expand it.
xform/rewriter.cpp
+
21
−
5
View file @
8186603a
...
...
@@ -669,6 +669,16 @@ void Rewriter::readXrefsFile(char p_filename[])
break
;
// check for instr xref ibt
/*
4280c0 1 INSTR XREF IBT FROMIB 426558 RETURNTARGET
426614 1 INSTR XREF IBT FROMIB 426580 RETURNTARGET
4280c0 1 INSTR XREF IBT FROMIB 426580 RETURNTARGET
4269d2 1 INSTR XREF IBT FROMIB 42689c RETURNTARGET
4432bd 1 INSTR XREF IBT FROMIB 42689c RETURNTARGET
447d4f 1 INSTR XREF IBT FROMIB 42689c RETURNTARGET
42689c 1 INSTR XREF FROMIB COMPLETE 3 RETURNTARGET
*/
if
(
string
(
"IBT"
)
==
string
(
ibt
))
{
fscanf
(
fin
,
"%s"
,
fromib
);
...
...
@@ -685,9 +695,10 @@ void Rewriter::readXrefsFile(char p_filename[])
instr
->
setIBTAddress
(
addr
);
if
(
strcmp
(
fromib
,
"FROMIB"
)
==
0
)
{
char
provenance
[
200
];
// get the from point into memory.
app_iaddr_t
from_addr
=
0
;
fscanf
(
fin
,
"%p"
,
(
void
**
)
&
from_addr
);
fscanf
(
fin
,
"%p
%s
"
,
(
void
**
)
&
from_addr
,
provenance
);
if
(
feof
(
fin
))
// deal with blank lines at the EOF
break
;
...
...
@@ -697,6 +708,7 @@ void Rewriter::readXrefsFile(char p_filename[])
// record in the IR listing.
from_instr
->
addIBT
(
instr
);
from_instr
->
setIbProvenance
(
provenance
);
}
}
}
...
...
@@ -706,17 +718,21 @@ void Rewriter::readXrefsFile(char p_filename[])
// annotations can come in any order so the COMPLETE annotation for IB targets
// can come before/after the targets themselves
// in this loop, just keep track of instructions w/ complete targets
// 4004b6 1 INSTR XREF FROMIB COMPLETE 1
// 4004b6 1 INSTR XREF FROMIB COMPLETE 1
<provenance>
char
complete
[
200
];
fscanf
(
fin
,
"%s"
,
complete
);
if
(
feof
(
fin
))
// deal with blank lines at the EOF
break
;
if
(
strcmp
(
complete
,
"COMPLETE"
)
==
0
)
{
char
provenance
[
200
];
int
num_targets
;
completeIBT
.
insert
(
addr
);
fscanf
(
fin
,
"%d %s"
,
&
num_targets
,
provenance
);
if
(
feof
(
fin
))
// deal with blank lines at the EOF
break
;
}
if
(
feof
(
fin
))
// deal with blank lines at the EOF
break
;
}
char
remainder
[
2000
];
...
...
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