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
f4e35989
Commit
f4e35989
authored
7 years ago
by
mc2zk
Browse files
Options
Downloads
Plain Diff
Bringing up to date with trunk
parents
540ff0df
82129585
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
push64_relocs.cpp
+18
-9
18 additions, 9 deletions
push64_relocs.cpp
with
18 additions
and
9 deletions
push64_relocs.cpp
+
18
−
9
View file @
f4e35989
...
...
@@ -30,6 +30,7 @@
#include
<zipr_sdk.h>
#include
<libIRDB-core.hpp>
#include
<string>
#include
<algorithm>
#include
"utils.hpp"
...
...
@@ -41,16 +42,19 @@ using namespace std;
using
namespace
Zipr_SDK
;
using
namespace
ELFIO
;
#define ALLOF(a) begin(a), end(a)
/*
bool arg_has_relative(const ARGTYPE &arg)
{
/
*
if it's relative memory, watch out!
*/
/
/
if it's relative memory, watch out!
if(arg.ArgType&MEMORY_TYPE)
if(arg.ArgType&RELATIVE_)
return true;
return false;
}
*/
Push64Relocs_t
::
Push64Relocs_t
(
MemorySpace_t
*
p_ms
,
elfio
*
p_elfio
,
...
...
@@ -317,8 +321,8 @@ void Push64Relocs_t::UpdatePush64Adds()
int
existing_offset_size
=
0
;
uint8_t
*
insn_bytes
=
NULL
;
int
insn_bytes_len
=
0
;
DISASM
d
;
ARGTYPE
*
arg
=
NULL
;
//
DISASM d;
//
ARGTYPE *arg=NULL;
#if 1
insn_addr
=
final_insn_locations
[
insn
];
if
(
insn_addr
==
0
)
...
...
@@ -333,7 +337,8 @@ void Push64Relocs_t::UpdatePush64Adds()
insn_bytes
=
(
uint8_t
*
)
malloc
(
insn_bytes_len
);
memcpy
(
insn_bytes
,
insn
->
GetDataBits
().
c_str
(),
insn_bytes_len
);
insn
->
Disassemble
(
d
);
DecodedInstruction_t
d
(
insn
);
/* Disassemble(insn,d);
if(arg_has_relative(d.Argument1))
arg=&d.Argument1;
...
...
@@ -341,11 +346,15 @@ void Push64Relocs_t::UpdatePush64Adds()
arg=&d.Argument2;
if(arg_has_relative(d.Argument3))
arg=&d.Argument3;
assert(arg);
memory_offset
=
arg
->
Memory
.
DisplacementAddr
-
d
.
EIP
;
existing_offset_size
=
arg
->
Memory
.
DisplacementSize
;
*/
const
auto
operands
=
d
.
getOperands
();
const
auto
arg_it
=
find_if
(
ALLOF
(
operands
),[](
const
DecodedOperand_t
&
op
)
{
return
op
.
isMemory
()
&&
op
.
isPcrel
();
});
assert
(
arg_it
!=
operands
.
end
());
const
auto
arg
=*
arg_it
;
memory_offset
=
d
.
getMemoryDisplacementOffset
(
arg
,
insn
);
// arg->Memory.DisplacementAddr-d.EIP;
existing_offset_size
=
arg
.
getMemoryDisplacementEncodingSize
();
// arg->Memory.DisplacementSize;
assert
(
memory_offset
>=
0
&&
memory_offset
<=
15
&&
(
existing_offset_size
==
1
||
existing_offset_size
==
2
||
...
...
@@ -362,7 +371,7 @@ void Push64Relocs_t::UpdatePush64Adds()
<<
std
::
hex
<<
existing_offset
<<
" existing offset at 0x"
<<
insn_addr
<<
"."
<<
endl
<<
"Based on: "
<<
d
.
CompleteInstr
<<
endl
<<
"Based on: "
<<
d
.
getDisassembly
()
/*
CompleteInstr
*/
<<
endl
<<
"New address: 0x"
<<
std
::
hex
<<
new_offset
<<
endl
;
m_memory_space
.
PlopBytes
(
insn_addr
+
memory_offset
,
...
...
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