@@ -1823,21 +1823,20 @@ phdrsize equ $ - phdr
18231823 mov rax , $ - $$
18241824%endmacro
18251825
1826+ ; Args -> variable_name (string without quotes)
1827+ ;
1828+ ; Same as above, but populates 'fsize' variable instead of returning size in RAX.
1829+ %macro get_current_size_var 0 - 1 fsize
1830+ % 1 equ $ - $$
1831+ %endmacro
1832+
18261833; Args -> None
18271834;
18281835; Returns number of bytes (in RAX) from the point where the macro was invoked to the end of file
18291836%macro get_current_size_end 0
18301837
18311838%endmacro
18321839
1833- ; Args -> variable_name (string without quotes)
1834- ;
1835- ; Same as above, but populates 'fsize' variable instead of returning size in RAX.
1836- ;%macro get_current_size_var 0-1 fsize
1837- ; %1 equ $-$$
1838- ;%macro
1839-
1840-
18411840; ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ [ = 0x12 = ] ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
18421841
18431842; Args -> source with *argv0 string (register)
@@ -1857,7 +1856,7 @@ phdrsize equ $ - phdr
18571856 pop rax
18581857 push % 1
18591858 pop r13
1860- cmp r13 , % 1
1859+ cmp r13 , 0xffffffff
18611860 je %%load_argv0_from_stack:
18621861 push % 1
18631862 pop rdi
@@ -1888,36 +1887,43 @@ phdrsize equ $ - phdr
18881887 %%no_remove:
18891888%endmacro
18901889
1890+ ; Args -> None
1891+ ;
1892+ ; Has the same effect as above macro, but removal is non-conditional
1893+ %macro remove_self_instant 0
1894+
1895+ %endmacro
1896+
18911897; Args -> [num_tables] (int)
18921898;
18931899; Initialize a given number of huge pages (2MB each)
18941900; Argument num_tables is optional, and defaults to 15
1895- %macro init_hgtbl 0 - 1 0x0f
1896- push SYS_EXECVE
1897- pop rax
1898- cdq
1899- %%shell_name: "//bin/sh"
1900- rel_load rcx , %%shell_name
1901- mov rcx , '//bin/sh'
1902- push rdx
1903- push rcx
1904- push rsp
1905- pop rdi
1906- push rdx
1907- push word '-c'
1908- push rsp
1909- pop rbx
1910- push rdx
1911- .cmd_load:
1912- call .x_cmd
1913- db "ht_enabled=$(grep HugePages_Total /proc/meminfo | awk ' {print $ NF} ')" , 0x3b , 0x00
1914- .x_cmd:
1915- push rbx
1916- push rdi
1917- push rsp
1918- pop rsi
1919- syscall
1920- %endmacro
1901+ ; %macro init_hgtbl 0-1 0x0f
1902+ ; push SYS_EXECVE
1903+ ; pop rax
1904+ ; cdq
1905+ ; %%shell_name: "//bin/sh"
1906+ ; rel_load rcx, %%shell_name
1907+ ; mov rcx, '//bin/sh'
1908+ ; push rdx
1909+ ; push rcx
1910+ ; push rsp
1911+ ; pop rdi
1912+ ; push rdx
1913+ ; push word '-c'
1914+ ; push rsp
1915+ ; pop rbx
1916+ ; push rdx
1917+ ; .cmd_load:
1918+ ; call .x_cmd
1919+ ; db "ht_enabled=$(grep HugePages_Total /proc/meminfo | awk '{print $NF}')", 0x3b, 0x00
1920+ ; .x_cmd:
1921+ ; push rbx
1922+ ; push rdi
1923+ ; push rsp
1924+ ; pop rsi
1925+ ; syscall
1926+ ; %endmacro
19211927
19221928; Args -> dir (string)
19231929;
0 commit comments