mirror of
https://github.com/upx/upx
synced 2025-09-28 19:06:07 +08:00
Check return value from syscalls; leave debugging hint if error
modified: stub/src/amd64-linux.elf-so_entry.S
This commit is contained in:
parent
0901ce1b68
commit
ecc9c67e1f
|
@ -204,13 +204,13 @@ eof_n2b:
|
||||||
|
|
||||||
push $0; pop %arg2
|
push $0; pop %arg2
|
||||||
call 0f; .asciz "upx"; 0: pop %arg1
|
call 0f; .asciz "upx"; 0: pop %arg1
|
||||||
mov $__NR_memfd_create,%rax; call do_sys
|
push $__NR_memfd_create; call do_sys
|
||||||
|
|
||||||
push %rax; pop %arg1 // mfd
|
push %rax; pop %arg1 // mfd
|
||||||
push %rsp; pop %arg2 // buffer
|
push %rsp; pop %arg2 // buffer
|
||||||
push %rax // MATCH_47 save mfd
|
push %rax // MATCH_47 save mfd
|
||||||
mov -2*NBPW(%rbp),%arg3 // length
|
mov -2*NBPW(%rbp),%arg3 // length
|
||||||
push $__NR_write; pop %rax; call do_sys // scribbles %rcx !!
|
push $__NR_write; call do_sys // scribbles %rcx !!
|
||||||
|
|
||||||
// Map unfolded code the SELinux way
|
// Map unfolded code the SELinux way
|
||||||
pop %arg5 // MATCH_47 mfd
|
pop %arg5 // MATCH_47 mfd
|
||||||
|
@ -220,11 +220,11 @@ eof_n2b:
|
||||||
push $MAP_PRIVATE; pop %sys4
|
push $MAP_PRIVATE; pop %sys4
|
||||||
push $PROT_READ|PROT_EXEC; pop %arg3
|
push $PROT_READ|PROT_EXEC; pop %arg3
|
||||||
subl %edi,%edi // (%arg1)dst = 0; // kernel chooses addr
|
subl %edi,%edi // (%arg1)dst = 0; // kernel chooses addr
|
||||||
push $__NR_mmap; pop %rax; call do_sys
|
push $__NR_mmap; call do_sys
|
||||||
push %rax // MATCH_11 ptr unfolded code
|
push %rax // MATCH_11 ptr unfolded code
|
||||||
|
|
||||||
push %arg5; pop %arg1 // mfd
|
push %arg5; pop %arg1 // mfd
|
||||||
push $__NR_close; pop %rax; call do_sys
|
push $__NR_close; call do_sys
|
||||||
|
|
||||||
// %rsp:
|
// %rsp:
|
||||||
// MATCH_11 ptr unfolded_code; for escape hatch
|
// MATCH_11 ptr unfolded_code; for escape hatch
|
||||||
|
@ -240,10 +240,10 @@ eof_n2b:
|
||||||
pop %rax; push %rax // MATCH_11 ptr unfolded code
|
pop %rax; push %rax // MATCH_11 ptr unfolded code
|
||||||
jmp *%rax // enter C code
|
jmp *%rax // enter C code
|
||||||
|
|
||||||
do_sys:
|
do_sys: // on-stack parameter: hint on error
|
||||||
syscall
|
mov NBPW(%rsp),%rax; syscall
|
||||||
cmp $-4096,%rax; jb 0f; int3; 0:
|
cmp $-4096,%rax; jb 0f; int3; 0:
|
||||||
ret
|
ret $NBPW
|
||||||
|
|
||||||
// IDENTSTR goes here
|
// IDENTSTR goes here
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user