Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
magic-lantern
magic-lantern
Commits
8b3116da2fc8
Commit
f27b43b3
authored
Sep 07, 2017
by
alex@thinkpad
Browse files
reloc: allow up to 16 fixups; fix stop condition
--HG-- branch : patchmgr
parent
800c173fda82
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/reloc.c
View file @
8b3116da
...
...
@@ -45,6 +45,7 @@ int verbose = 1;
/**
* Search through a memory region, looking for branch instructions
* Returns a pointer to the new func_offset address.
* Requires 64 bytes for fixups.
*/
uintptr_t
reloc
(
...
...
@@ -55,7 +56,6 @@ reloc(
uintptr_t
new_pc
)
{
uintptr_t
pc
;
uint8_t
*
const
mem
=
((
uint8_t
*
)
buf
)
-
load_addr
;
// const uintptr_t func_len = func_end - func_offset;
...
...
@@ -63,11 +63,11 @@ reloc(
printf
(
"Fixing from %08x to %08x
\n
"
,
func_offset
,
func_end
);
#endif
// Add up to
1
6 bytes of fixups
// Add up to 6
4
bytes of fixups
uintptr_t
fixups
=
new_pc
;
uintptr_t
entry
=
new_pc
+=
1
6
;
uintptr_t
entry
=
new_pc
+=
6
4
;
for
(
pc
=
func_offset
;
pc
<=
func_end
;
pc
+=
4
,
new_pc
+=
4
)
for
(
uintptr_t
pc
=
func_offset
;
pc
<
func_end
;
pc
+=
4
,
new_pc
+=
4
)
{
uint32_t
instr
=
*
(
uint32_t
*
)(
mem
+
pc
);
uint32_t
branch
=
instr
&
BRANCH_MASK
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment