Skip to content

Commit

Permalink
Correcting pointer access to top of stack
Browse files Browse the repository at this point in the history
The current implementation always retrieves the deepest LR and TOC (belonging to very first patch) from the stack. Since, r5 contains base of stack and "decremented USED_SIZE" is not added to point to top of stack, so r5 keep pointing to bottom when retrieving LR/TOC values for any patched function.
  • Loading branch information
dubeyabhishek authored and giulianobelinassi committed Feb 10, 2025
1 parent c0ec585 commit 34b8dcd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/arch/powerpc64le/ulp_prologue.S
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ trampoline_routine:
# Load ulp_stack ptr field.
ld %r5, ULP_STACK_PTR(%r5)

# Point to the top of stack but two, these two entries are popped in
# previous step and accessed in next step (stack size decremented before access).
add %r5, %r5, %r6 # ulp_stack + used_size

# Restore saved data.
ld %r2, 0(%r5) # Restore TOC
ld %r8, 8(%r5) # Restore LR
Expand Down

0 comments on commit 34b8dcd

Please sign in to comment.