This Repository is a collection of different ethical hacking tools and malware's for penetration testing and research purpose written in python, ruby, rust, c++, go and c.
JavaScript algorithmsartificial-intelligencebugbountycryptographycyber-threat-intelligencecybersecurity-projectsethical-hackinghacking-toolsmalwarenessusnetwork-monitoringnetwork-securitynmapportscannerpythonpythonprojectsthreat-intelligencevirus-scanning
The Link Register (LR) in ARM64 architecture is a special-purpose register (register X30) used to store the return address for function calls. When a function is called using the BL (Branch with Link) instruction, the return address (the address of the next instruction after the BL) is stored in the LR. After the function completes, the program can return to the caller by branching to the address stored in the LR.
A simple ARM64 assembly code demo to illustrate how the Link Register works:
ARM64 Assembly Code Example
.global _start
_start:
// Main program starts here
MOV X0, #1 // Load value 1 into register X0
MOV X1, #2 // Load value 2 into register X1
BL add_numbers // Call the function 'add_numbers'
// The return address (next instruction) is stored in LR (X30)
// After returning from the function
B end_program // Branch to end_program to exit
add_numbers:
// Function to add two numbers
ADD X0, X0, X1 // Add X0 and X1, result in X0
RET // Return to the address stored in LR (X30)
end_program:
// End of program
MOV X0, #0 // Set return value to 0
MOV X8, #93 // syscall: exit
SVC #0 // Make the system call
Explanation of the Code
_start:- This is the entry point of the program.
- The program loads values
1and2into registersX0andX1, respectively. - The
BL add_numbersinstruction calls theadd_numbersfunction. The address of the next instruction (afterBL) is stored in the Link Register (X30).
add_numbers:- This function adds the values in
X0andX1and stores the result inX0. - The
RETinstruction branches to the address stored in the Link Register (X30), effectively returning control to the caller.
- This function adds the values in
end_program:- After returning from the function, the program branches to
end_program. - The program sets the return value to
0and makes a system call to exit.
- After returning from the function, the program branches to
How the Link Register Works
When
BL add_numbersis executed:- The address of the next instruction (after
BL) is saved in the Link Register (X30). - The program counter (
PC) is updated to the address ofadd_numbers.
- The address of the next instruction (after
When
RETis executed:- The program counter (
PC) is set to the value stored in the Link Register (X30), which is the return address. - This allows the program to continue execution from where the function was called.
- The program counter (
Key Points
- The Link Register (
X30) is used to store the return address for function calls. - The
BLinstruction automatically saves the return address inX30. - The
RETinstruction uses the value inX30to return to the caller.