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
59b7b906
Commit
59b7b906
authored
5 years ago
by
Jason Hiser
Browse files
Options
Downloads
Patches
Plain Diff
added file-base conversion factor into absptr. may need it for others in the future
parent
c129d094
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
unpin_x86.cpp
+19
-6
19 additions, 6 deletions
unpin_x86.cpp
with
19 additions
and
6 deletions
unpin_x86.cpp
+
19
−
6
View file @
59b7b906
...
...
@@ -149,34 +149,47 @@ void UnpinX86_t::HandlePcrelReloc(Instruction_t* from_insn, Relocation_t* reloc)
void
UnpinX86_t
::
HandleAbsptrReloc
(
Instruction_t
*
from_insn
,
Relocation_t
*
reloc
)
{
// decode the instruction
const
auto
disasm
=
DecodedInstruction_t
::
factory
(
from_insn
);
const
auto
operands
=
disasm
->
getOperands
();
// find the memory operand
// push/pop from memory might have a memory operand with no string to represent the implicit stack operand.
const
auto
the_arg_it
=
find_if
(
ALLOF
(
operands
),[](
const
shared_ptr
<
DecodedOperand_t
>&
op
){
return
op
->
isMemory
()
&&
op
->
getString
()
!=
""
;
});
DataScoop_t
*
wrt
=
dynamic_cast
<
DataScoop_t
*>
(
reloc
->
getWRT
());
const
auto
wrt
=
dynamic_cast
<
DataScoop_t
*>
(
reloc
->
getWRT
());
// assert we found the right thing
assert
(
wrt
);
assert
(
the_arg_it
!=
operands
.
end
());
const
auto
&
the_arg
=*
the_arg_it
;
int
disp_offset
=
disasm
->
getMemoryDisplacementOffset
(
the_arg
.
get
(),
from_insn
);
int
disp_size
=
the_arg
->
getMemoryDisplacementEncodingSize
();
// extract the info about where the displacement encoding is
const
auto
disp_offset
=
uint32_t
(
disasm
->
getMemoryDisplacementOffset
(
the_arg
.
get
(),
from_insn
));
const
auto
disp_size
=
uint32_t
(
the_arg
->
getMemoryDisplacementEncodingSize
());
assert
(
disp_size
==
4
);
assert
(
0
<
disp_offset
&&
(
int64_t
)
disp_offset
<=
(
int64_t
)
from_insn
->
getDataBits
().
size
()
-
disp_size
);
assert
(
reloc
->
getWRT
());
unsigned
int
new_disp
=
the_arg
->
getMemoryDisplacement
()
+
wrt
->
getStart
()
->
getVirtualOffset
();
// calculate the new displcement
const
auto
new_disp
=
uint32_t
(
the_arg
->
getMemoryDisplacement
()
+
wrt
->
getStart
()
->
getVirtualOffset
()
+
reloc
->
getAddend
()
-
firp
.
getArchitecture
()
->
getFileBase
());
// update the instruction
from_insn
->
setDataBits
(
from_insn
->
getDataBits
().
replace
(
disp_offset
,
disp_size
,
(
char
*
)
&
new_disp
,
disp_size
));
// update the instruction in the memory space.
IRDB_SDK
::
VirtualOffset_t
from_insn_location
=
locMap
[
from_insn
];
const
auto
from_insn_location
=
locMap
[
from_insn
];
for
(
unsigned
int
i
=
0
;
i
<
from_insn
->
getDataBits
().
size
();
i
++
)
{
unsigned
char
newbyte
=
from_insn
->
getDataBits
()[
i
];
const
auto
newbyte
=
from_insn
->
getDataBits
()[
i
];
ms
[
from_insn_location
+
i
]
=
newbyte
;
//cout<<"Updating push["<<i<<"] from "<<hex<<oldbyte<<" to "<<newbyte<<endl;
}
// decode again for logging
const
auto
disasm2
=
DecodedInstruction_t
::
factory
(
from_insn
);
// log
cout
<<
"unpin:absptr_to_scoop:Converting "
<<
hex
<<
from_insn
->
getBaseID
()
<<
":"
<<
disasm
->
getDisassembly
()
<<
" to "
<<
disasm2
->
getDisassembly
()
<<
" for scoop: "
<<
wrt
->
getName
()
<<
endl
;
}
...
...
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