Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 101715
b: refs/heads/master
c: 053a858
h: refs/heads/master
i:
  101713: 13dd31d
  101711: c6b9670
v: v3
  • Loading branch information
Michael Ellerman authored and Paul Mackerras committed Jul 1, 2008
1 parent c103755 commit 49b8dd5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e7a57273c6407bb6903fbaddec8c2119bf318617
refs/heads/master: 053a858efa46c9ab86363b271374ec02ad2af753
10 changes: 8 additions & 2 deletions trunk/arch/powerpc/lib/code-patching.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,18 @@ unsigned int create_branch(const unsigned int *addr,
unsigned long target, int flags)
{
unsigned int instruction;
long offset;

offset = target;
if (! (flags & BRANCH_ABSOLUTE))
target = target - (unsigned long)addr;
offset = offset - (unsigned long)addr;

/* Check we can represent the target in the instruction format */
if (offset < -0x2000000 || offset > 0x1fffffc || offset & 0x3)
return 0;

/* Mask out the flags and target, so they don't step on each other. */
instruction = 0x48000000 | (flags & 0x3) | (target & 0x03FFFFFC);
instruction = 0x48000000 | (flags & 0x3) | (offset & 0x03FFFFFC);

return instruction;
}

0 comments on commit 49b8dd5

Please sign in to comment.