summaryrefslogtreecommitdiff
path: root/exec/loader-x86_64.s
diff options
context:
space:
mode:
authorPo Lu <luangruo@yahoo.com>2023-05-02 16:44:46 +0800
committerPo Lu <luangruo@yahoo.com>2023-05-02 16:44:46 +0800
commitf4512cca0b996e5343ebe57511f45a29f64c4a8e (patch)
treed7eca09f5d2f3a4db3b10212c10e66e24253c046 /exec/loader-x86_64.s
parent5a58a6bc477f290ee0b8a6111e92df56ff538719 (diff)
downloademacs-f4512cca0b996e5343ebe57511f45a29f64c4a8e.tar.gz
Fix ps name in Android subprocesses
* exec/Makefile.in (.SUFFIXES): Include ., then `srcdir'. * exec/loader-aarch64.s (_start): * exec/loader-armeabi.s (_start): * exec/loader-mips64el.s (__start): * exec/loader-mipsel.s (__start): * exec/loader-x86.s (_start): * exec/loader-x86_64.s (_start): Get basename of opened exec file and make it the command name. Fix envp skipping on x86 and various leaks.
Diffstat (limited to 'exec/loader-x86_64.s')
-rw-r--r--exec/loader-x86_64.s29
1 files changed, 22 insertions, 7 deletions
diff --git a/exec/loader-x86_64.s b/exec/loader-x86_64.s
index 07227d38396..acba609b202 100644
--- a/exec/loader-x86_64.s
+++ b/exec/loader-x86_64.s
@@ -21,10 +21,10 @@ CC along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
.section .text
.global _start
_start:
- #movq $35, %rax CC SYS_nanosleep
- #leaq timespec(%rip), %rdi
- #xorq %rsi, %rsi
- #syscall
+dnl movq $35, %rax CC SYS_nanosleep
+dnl leaq timespec(%rip), %rdi
+dnl xorq %rsi, %rsi
+dnl syscall
popq %r13 CC original SP
popq %r15 CC size of load area.
movq $-1, %r12 CC r12 is the interpreter fd
@@ -87,9 +87,16 @@ _start:
jle .perror
movq %rdi, %rsp CC rsp = start of string
subq $1, %rsp
+ movq %rsp, %r14 CC r14 = start of string
.nextc:
addq $1, %rsp
- cmpb $0, (%rsp) CC *rsp == 0?
+ movb (%rsp), %dil CC rdi = *rsp
+ cmpb $47, %dil CC *rsp == '/'?
+ jne .nextc1
+ movq %rsp, %r14 CC r14 = rsp
+ addq $1, %r14 CC r14 = char past separator
+.nextc1:
+ cmpb $0, %dil CC *rsp == 0?
jne .nextc
addq $8, %rsp CC adjust past rsp prior to rounding
andq $-8, %rsp CC round rsp up to the next quad
@@ -99,6 +106,14 @@ _start:
jmp .next_action
.primary:
movq %rax, %rbx CC if not, move fd to rbx
+ movq $157, %rax CC SYS_prctl
+ movq $15, %rdi CC PR_SET_NAME
+ movq %r14, %rsi CC arg1
+ xorq %rdx, %rdx CC arg2
+ xorq %r10, %r10 CC arg3
+ xorq %r8, %r8 CC arg4
+ xorq %r9, %r9 CC arg5
+ syscall
jmp .next_action
.perror:
movq %rax, %r12 CC error code
@@ -159,11 +174,11 @@ _start:
.cleanup:
movq $3, %rax CC SYS_close
cmpq $-1, %r12 CC see if interpreter fd is set
- jne .cleanup_1
+ je .cleanup_1
movq %r12, %rdi
syscall
-.cleanup_1:
movq $3, %rax CC SYS_close
+.cleanup_1:
movq %rbx, %rdi
syscall
.enter: