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
c129d094
Commit
c129d094
authored
5 years ago
by
Jason Hiser
Browse files
Options
Downloads
Patches
Plain Diff
Take file base into account for PE files
parent
0aa72542
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
+8
-7
8 additions, 7 deletions
unpin_x86.cpp
with
8 additions
and
7 deletions
unpin_x86.cpp
+
8
−
7
View file @
c129d094
...
...
@@ -104,7 +104,8 @@ void UnpinX86_t::HandlePcrelReloc(Instruction_t* from_insn, Relocation_t* reloc)
const
auto
the_arg
=*
the_arg_it
;
// get the new insn addr
const
auto
from_insn_location
=
(
VirtualOffset_t
)
locMap
[
from_insn
];
const
auto
from_insn_location_with_filebase
=
(
VirtualOffset_t
)
locMap
[
from_insn
];
const
auto
from_insn_location_no_file_base
=
from_insn_location_with_filebase
-
firp
.
getArchitecture
()
->
getFileBase
();
// get WRT info
IRDB_SDK
::
VirtualOffset_t
to_addr
=
0xdeadbeef
;
// noteable value that shouldn't be used.
...
...
@@ -134,15 +135,15 @@ void UnpinX86_t::HandlePcrelReloc(Instruction_t* from_insn, Relocation_t* reloc)
assert
(
disp_size
==
4
);
assert
(
0
<
disp_offset
&&
(
int64_t
)
disp_offset
<=
(
int64_t
)
from_insn
->
getDataBits
().
size
()
-
disp_size
);
const
auto
new_disp
=
(
int
)(
rel_addr1
+
to_addr
-
from_insn
->
getDataBits
().
size
()
-
from_insn_location
);
const
auto
new_disp
=
(
int
)(
rel_addr1
+
to_addr
-
from_insn
->
getDataBits
().
size
()
-
from_insn_location
_no_file_base
);
const
auto
newbits
=
from_insn
->
getDataBits
().
replace
(
disp_offset
,
disp_size
,
(
char
*
)
&
new_disp
,
disp_size
);
from_insn
->
setDataBits
(
newbits
);
ms
.
plopBytes
(
from_insn_location
,
newbits
.
c_str
(),
newbits
.
size
());
ms
.
plopBytes
(
from_insn_location
_with_filebase
,
newbits
.
c_str
(),
newbits
.
size
());
const
auto
disasm2
=
DecodedInstruction_t
::
factory
(
from_insn
);
cout
<<
"unpin:pcrel:new_disp="
<<
hex
<<
new_disp
<<
endl
;
cout
<<
"unpin:pcrel:new_insn_addr="
<<
hex
<<
from_insn_location
<<
endl
;
cout
<<
"unpin:pcrel:Converting "
<<
hex
<<
from_insn
->
getBaseID
()
<<
":"
<<
disasm
->
getDisassembly
()
<<
" to "
<<
disasm2
->
getDisassembly
()
<<
" wrt "
<<
convert_string
<<
endl
;
cout
<<
"unpin:pcrel:new_disp="
<<
hex
<<
new_disp
<<
endl
;
cout
<<
"unpin:pcrel:new_insn_addr="
<<
hex
<<
from_insn_location
_with_filebase
<<
endl
;
cout
<<
"unpin:pcrel:Converting "
<<
hex
<<
from_insn
->
getBaseID
()
<<
":"
<<
disasm
->
getDisassembly
()
<<
" to "
<<
disasm2
->
getDisassembly
()
<<
" wrt "
<<
convert_string
<<
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