File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ class ShellcodePrimitivePrint(ShellcodePrimitive):
55 def __init__ (self , nickname : str , print_function : int , print_string : str ):
66 super ().__init__ (
77 nickname ,
8- ["print.S" , "utils .h" ],
8+ ["print.S" , "utils_asm .h" ],
99 "print.S" ,
1010 "print.h"
1111 )
Original file line number Diff line number Diff line change 11#include "print.h"
2+ #include "utils_asm.h"
3+
4+ .set noreorder
25
36.global start
47start:
58 // Save $ra
69 addiu $sp, -4
710 sw $ra, 0 ($sp)
811
9- // Get $pc using bal
10- bal code
11- nop
12- code:
13- // bal somehow compiles to "bal + nop" so 2 opcodes
14- addiu $a0, $ra, (print_string - code + 4 )
15- nop
12+ // Calculate address of `print_string`
13+ // relative to current $pc
14+ GET_PC($v0)
15+ GET_ADDRESS($a0, print_string, $v0)
1616
1717 lui $v0, %hi(PRINT_FUNCTION_ADDRESS)
1818 addiu $v0, %lo(PRINT_FUNCTION_ADDRESS)
@@ -27,10 +27,12 @@ code:
2727 // Jump over the printed string, to ensure we can run
2828 // another primitive after this one.
2929 b end_of_code
30+ nop
3031
3132print_string:
3233 .asciiz PRINT_STRING
3334 .align 2
3435
3536end_of_code:
3637 nop
38+
You can’t perform that action at this time.
0 commit comments