sudo apt-get install git libglib2.0-dev libfdt-dev libpixman-1-dev zlib1g-dev ninja-build
32 bit arm processors are still common as they are smaller!
MNEMONIC{S}{condition} {Rd}, Operand1, Operand2
MNEMONIC - Short name (mnemonic) of the instruction
{S} - An optional suffix
If specified, the condition flag is updated based on the result of the operaiton
ADD R0, R1, R2
ADD R0, R1, #2
MOVLE R0, #5
MOV R0, R1, LSL #1
Sounds almost exactly like x86 right?
Sounds almost exactly like x86 right?
push {r11, lr}
add r11, sp, #8
sub sp, sp, $16
mov r0, #1
mov r1, #2
bl some_func
sub sp, r11, #8
pop {r11, pc}
/* azeria@labs:~$ as func.s -o func.o && gcc func.o -o func && gdb func */
.global main
main:
push {r11, lr} /* Start of the prologue. Saving Frame Pointer and LR onto the stack */
add r11, sp, #0 /* Setting up the bottom of the stack frame */
sub sp, sp, #16 /* End of the prologue. Allocating some buffer on the stack */
mov r0, #1 /* setting up local variables (a=1). This also serves as setting up the first parameter for the max function */
mov r1, #2 /* setting up local variables (b=2). This also serves as setting up the second parameter for the max function */
bl max /* Calling/branching to function max */
sub sp, r11, #0 /* Start of the epilogue. Readjusting the Stack Pointer */
pop {r11, pc} /* End of the epilogue. Restoring Frame pointer from the stack, jumping to previously saved LR via direct load into PC */
max:
push {r11} /* Start of the prologue. Saving Frame Pointer onto the stack */
add r11, sp, #0 /* Setting up the bottom of the stack frame */
sub sp, sp, #12 /* End of the prologue. Allocating some buffer on the stack */
cmp r0, r1 /* Implementation of if(a<b) */
movlt r0, r1 /* if r0 was lower than r1, store r1 into r0 */
add sp, r11, #0 /* Start of the epilogue. Readjusting the Stack Pointer */
pop {r11} /* restoring frame pointer */
bx lr /* End of the epilogue. Jumping back to main via LR register */
https://azeria-labs.com/writing-arm-assembly-part-1/ - Seven part series
https://modexp.wordpress.com/2018/10/30/arm64-assembly/
https://medium.com/codex/reverse-engineering-bare-metal-low-level-kernel-images-with-qemu-getting-started-c705b7b14d35
https://medium.com/@ragnarsecurity/reverse-engineering-bare-metal-kernel-images-part-2-6a52a4afa3ef
https://medium.com/geekculture/reverse-engineering-bare-metal-firmware-part-3-analyzing-arm-assembly-and-exploiting-3b2dbe219f19
No class next week, will be replaced with office hours!
This week's office hours: Wednesday 5-6:30pm