Skip to content

Commit

Permalink
elfloader: fixup load from stack on aarch64
Browse files Browse the repository at this point in the history
It seems that the 'ldp x0, x1, [sp, #-16]!' syntax used to load the
registers stored to the stack before calling the fixup_image_base
function does not in fact load the registers as expected (at least
on my Raspberry Pi 3B).
This causes the dtb address supplied by the bootloader to be lost when
elfloader loads the dtb image which is an issue if a dtb is not built
into the kernel binary image.

In the example usage from arm
(https://developer.arm.com/documentation/
102374/0101/Loads-and-stores---load-pair-and-store-pair)
the 'ldp x0, x1, [sp], #16' is used for poping the stack.
This also seems to also work as expected on my Raspberry Pi 3B
resulting in the dtb address to be loaded as expected in sys_boot.c.

Signed-off-by: Viktor Sannum <[email protected]>
  • Loading branch information
sannum committed Jun 28, 2021
1 parent f0ca8fc commit 5805695
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion elfloader-tool/src/arch-arm/64/crt0.S
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ BEGIN_FUNC(_start)
bl fixup_image_base
mov x2, x0
/* restore original arguments for next step */
ldp x0, x1, [sp, #-16]!
ldp x0, x1, [sp], #16
/* fixup_image_base returns 1 if no need to move */
cmp x2, #1
beq 1f
Expand Down

0 comments on commit 5805695

Please sign in to comment.