1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-11-22 07:09:54 +00:00
Commit Graph

41 Commits

Author SHA1 Message Date
Po Lu
1b94f800ae * exec/trace.c (rpl_stpcpy): Replace stpcpy if absent. 2024-03-14 14:21:49 +08:00
Po Lu
30bc867aec Improve /proc/self/exe substitution on Android
* exec/configure.ac (USER_SWORD): New macro.

* exec/exec.c (format_pid): Export this function.

* exec/exec.h:

* exec/trace.c (canon_path): New function.
(handle_readlinkat, handle_openat): Test complete file name
against /proc/self/exe, and further check for /proc/pid/exe.
2024-03-14 13:45:48 +08:00
Po Lu
b9f348ce1e * exec/configure.ac (OPENAT_SYSCALL): Define on MIPS. 2024-01-29 11:54:46 +08:00
Po Lu
c37b50ad41 Intercept calls to `openat' under Android
* exec/configure.ac (OPEN_SYSCALL, OPENAT_SYSCALL): Define new
macros.

* exec/exec.h (struct exec_tracee): New field `sp'.

* exec/trace.c (handle_openat): New function.
(process_system_call): If handle_openat executes successfully,
save the unmodified stack pointer within the tracee structure to
be restored once the system call completes.
2024-01-27 10:36:30 +08:00
Po Lu
8da6c8c7c1 ; * exec/Makefile.in: Correct typo. 2024-01-21 09:59:47 +08:00
Po Lu
76efd4037e ; * exec/Makefile.in (extraclean): Remove standard files. 2024-01-21 09:59:47 +08:00
Paul Eggert
afc9cd1721 Fix autogen.sh’s spurious ‘git diff’ output
Problem reported by Gerd Möllmann (Bug#68464).
* .gitignore: Ignore files in exec that are now copied from build-aux.
* admin/merge-gnulib (avoided_flags): Instead of clearing
autom4te.cache here ...
* autogen.sh (do_git): ... clear it here.
Use config.guess, config.sub and install-sh from
the Emacs repository, as they are more likely to be up to date.
This avoids unnecessary differences among different builders,
and avoids unnecessary ‘git diff’ output after autogen.sh.
Also, copy these files from build-aux to exec since there
should be no difference between the two copies.
* exec/config.guess, exec/config.sub, exec/install-sh:
Remove from repository, as autogen.sh now copies them from build-aux.
2024-01-20 16:35:24 -08:00
Po Lu
d2528f5c0f ; Update copyright years in more files 2024-01-02 10:31:42 +08:00
Po Lu
070cb32463 ; Add 2024 to copyright years 2024-01-02 10:30:05 +08:00
Stefan Kangas
c3b41c123a ; Use ?c instead of integer in local variables
* exec/loader-armeabi.s (timespec):
* exec/loader-mips64el.s (__start):
* exec/loader-mipsel.s (__start): Use ?c instead of integer in local
variables.
2023-12-10 22:09:56 +01:00
Stefan Kangas
06a12b0ccc ; Fix typos 2023-12-10 13:22:04 +01:00
Po Lu
fb0198bf7e ; Update Autoconf auxiliaries in exec
* exec/config.guess:

* exec/config.sub: Update configury files.
2023-11-26 08:28:45 +08:00
Po Lu
b331bf6d8a Correct build on systems without PAGE_MASK
* exec/exec.c (write_load_command) <PAGE_MASK, PAGE_SIZE>:
Uniformly define even if !HAVE_GETPAGESIZE.
2023-09-18 14:16:40 +08:00
Po Lu
cd69120731 Correct crash in child processes under armeabi Android
* exec/trace.c (process_system_call) <READLINKAT_SYSCALL>:
Examine tracee->waiting_for_syscall and avoid rewriting user
arguments if a system call is presently being executed by the
kernel.  Reported by Romário Rios <romariorios@protonmail.com>.
2023-09-18 14:16:39 +08:00
Paul Eggert
5315e6e8d7 Avoid stpncpy
It’s not worth the porting hassle, and as the glibc manual says,
“this function is generally a poor choice for processing strings”.
* admin/merge-gnulib (GNULIB_MODULES): Remove stpncpy.
* exec/configure.ac: Do not check for stpncpy.
* exec/exec.c (rpl_stpncpy, stpncpy): Remove this replacement.
(exec_0): Properly clear buffer1.  Use memcpy instead of
stpncpy to add the trailing name.  This code is clearly
still suboptimal but efficiency is not that important here
and I tried to minimize the change.
* lib/gnulib.mk.in, m4/gnulib-comp.m4: Regenerate.
2023-08-12 12:57:35 -07:00
Eli Zaretskii
b289f0769f Merge from origin/emacs-29
4767f5eaee Better fix for bug#65156
dd1d8414b3 Fix insert-file-contents with pipes and /dev/stdin
50649a6d1a ; * etc/PROBLEMS: Fix wording.
f0dda682ff ; * etc/NEWS.28: Add deletion of levents.el.
f4acae842c Fix bug#65042
e1874c4e8b * configure.ac (HAVE_TREE_SITTER): Set NEED_DYNLIB=yes (b...
ef8838c3a5 * etc/NEWS: Mention tramp-show-ad-hoc-proxies.
495bee253f * test/lisp/net/tramp-tests.el (tramp-test42-utf8): Skip ...
de1effd73b ; Fix last change
7c7966862b * test/lisp/net/tramp-tests.el (tramp-test10-write-region...
16205e8db6 ; Improve help-echo in package.el
a95e700698 ; Filter packages available for upgrade via menu bar
adff72dd1d Fix reverting Rmail buffers
2023-08-12 13:42:14 -04:00
Po Lu
f74166c726 Stop tracking exec/config.h.in
* .gitignore: Add exec/config.h.in.

* exec/config.h.in: Remove from Git.
2023-08-07 20:15:33 +08:00
Po Lu
916ef57489 Update Android port
* exec/trace.c (handle_readlinkat): Adjust commentary to match
behavior.
* src/android.c (android_get_keysym_name): NULL terminate
*name_return.
2023-07-20 20:50:50 +08:00
Po Lu
32352bec96 ; * exec/loader-mips64el.s (rest_of_exec): Fix typo in comment. 2023-06-27 09:53:04 +08:00
Po Lu
0bdeb217fc ; * exec/Makefile.in (clean): Add `exec1'. 2023-06-19 08:56:49 +08:00
Po Lu
456095ed31 Update Android port
* exec/exec.c (insert_args): New argument `arg3'.  Replace
argv[1] with that argument.
(exec_0): Pass file name of script to `insert_args'.
2023-05-31 11:27:19 +08:00
Po Lu
1145572af2 ; * exec/exec.c (exec_0): Use strcpy. 2023-05-23 09:22:19 +08:00
Po Lu
d86643a786 Remove arbitrary process count limit
* exec/trace.c (handle_clone_prepare):
(handle_clone): When !REENTRANT, use malloc to allocate
tracees after running out of static ones.
2023-05-20 16:54:13 +08:00
Po Lu
0fbe79727b Fix execution of /proc/self/exe within child processes
* exec/exec.h (struct exec_tracee): New field `new_child'.
Also, make `waiting_for_syscall' a bitfield.
* exec/trace.c (PTRACE_GETEVENTMSG): New declaration.
(MAX_TRACEES): Bump to 4096.
(handle_clone_prepare): New function.
(handle_clone): If required, set `new_child' and wait for a
ptrace event describing the parent to arrive.
(after_fork): Clear new field.
(exec_waitpid): Upon a ptrace event describing a clone, create
the child's tracee if it doesn't already exist.  Otherwise, copy
over the parent's cmdline and start running it.
2023-05-05 19:04:32 +08:00
Po Lu
2ba6c5035c Update Android port
* doc/emacs/android.texi (Android Environment): Document lossage
with SIGSTOP.
* exec/exec.c (exec_0): Check X_OK on file being opened.  Also
handle /proc/self/exe.
2023-05-05 12:10:14 +08:00
Po Lu
d5414f1797 Update Android port
* exec/trace.c (SYS_SECCOMP): Define when not present.
2023-05-05 10:57:26 +08:00
Po Lu
339cdef28e Update Android port
* exec/trace.c (check_signal): New function.
(handle_exec, process_system_call): Handle signal-delivery-stop
while waiting synchronously for syscall completion.
2023-05-04 09:12:26 +08:00
Po Lu
b0d6c67372 Update Android port
* exec/config.h.in: Autoheader.
* exec/configure.ac: Check for siginfo_t.si_syscall.
* exec/trace.c (exec_waitpid): If SIGSYS is received, and caused by
seccomp, drop it should the call number be the invalid system call
used by Emacs.
2023-05-03 17:01:44 +08:00
Po Lu
7b3c774bce Update Android port
* exec/config.h.in: Autoheader.
* exec/configure.ac: Use system extensions.
(HAVE_PROCESS_VM): Define if process_vm_readv and
process_vm_writev are available.
* exec/trace.c (read_memory, user_copy): Implement in terms of
process_vm if possible.
2023-05-03 16:00:13 +08:00
Po Lu
35eae084bc Remove extra debugging code
* exec/loader-mipsel.s (__start): Remove extraneous debugging
code.
2023-05-03 09:23:06 +08:00
Po Lu
d5b92bce5b Update Android port
* exec/Makefile.in: (.PHONY): Add `bootstrap-clean' and
`extraclean'.
(bootstrap-clean): New rule.
2023-05-03 07:53:38 +08:00
Po Lu
c47716f95b Update Android port
* exec/config.h.in (__bool_true_false_are_defined):
* exec/configure.ac (REENTRANT): New definition.
(READLINKAT_SYSCALL, READLINK_SYSCALL): New defines.  Set on all
hosts.
* exec/exec.c (MIN, MAX): Remove redundant declarations.  Move
to config.h.
(exec_0): Copy name of executable into NAME when !REENTRANT.
* exec/exec.h (struct exec_tracee): New struct `exec_file'.
* exec/trace.c (remove_tracee, handle_exec, handle_readlinkat)
(process_system_call, after_fork): Handle readlinkat system
calls.
2023-05-02 20:45:57 +08:00
Po Lu
f4512cca0b 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.
2023-05-02 16:44:46 +08:00
Po Lu
5a58a6bc47 Port Android port to older Android systems
* exec/config.h.in: Autoheader.
* exec/configure.ac: Check for declarations of stpcpy and
stpncpy.
* exec/exec.c (stpcpy, stpncpy): Use replacements if
declarations are not present; this happens when a new Android
NDK is building for an old version of Android.
2023-05-02 08:16:00 +08:00
Po Lu
f92bdbc677 Update Android port
* exec/config.h.in: Update config.h.in.
* exec/configure.ac: Check for stpcpy and stpncpy.
* exec/exec.c (rpl_stpcpy, rpl_stpncpy): Define replacements
when they are not present on the system.
(process_program_header): Fill comment.
2023-05-01 21:42:42 +08:00
Po Lu
b9de6e35b7 Fix cwd relative process execution on Android
* exec/exec.c (format_pid): New function.
(exec_0): Make cwd relative file names relative to
/proc/pid/cwd.
* exec/trace.c (handle_exec): Handle EINTR.
(process_system_call): Report failure without clobbering x0.
2023-05-01 21:23:12 +08:00
Po Lu
6a30a74cb2 Fix syscall error reporting on aarch64
* exec/trace.c (process_system_call): Save and restore x0, x1
and x2 regs after replacing them with an invalid file
descriptor.
2023-05-01 13:12:44 +08:00
Po Lu
ddc16de869 Update Android port
* Makefile.in (extraclean): Clean in exec as well.
* configure.ac: Fix detection of absolute srcdir.  Also, pass
CFLAGS.
* exec/Makefile.in: (.c.o): Add -I. so config.h can be
found.:(.s.o): Don't create m4 temporary in srcdir.
* exec/config-mips.m4.in (DADDI2, DADDI3): New macros.  Define
to substitute if as cannot assemble daddi.
* exec/configure.ac (user_h): Look for user.h in asm/ as well.
Use new user.h.  Also look in ptrace.h on arm systems.  Check if
as supports daddi on mips64.
* exec/exec.c (check_interpreter): Fix char signedness bug.
* exec/loader-mips64el.s (__start): Use DADDI2 and DADDI3 for
two- and 3-operand daddi.
* exec/mipsel-user.h: Don't include sgidefs.h.
* java/INSTALL: Document that m4 is now required.
* src/android.c (android_rewrite_spawn_argv): Add missing NULL.
2023-05-01 11:28:22 +08:00
Po Lu
5550816f59 Work around system restrictions regarding exec
* doc/emacs/android.texi (Android Environment): Document
`android-use-exec-loader'.
* exec/exec1.c (main): Set program group of child process.
* src/android.c (android_rewrite_spawn_argv): New function.
* src/android.h: Update prototypes.
* src/androidfns.c (syms_of_androidfns): New variable
`android_use_exec_loader'.
* src/callproc.c (emacs_spawn): Rewrite the argument vector to
use exec1 if necessary.
2023-05-01 09:31:58 +08:00
Po Lu
9a7c645dd4 Remove exec/configure
* exec/configure: Remove file.
* .gitignore: Add exec/configure.
2023-05-01 08:15:48 +08:00
Po Lu
368f6f3942 Add helper binary `exec1'
* .gitignore: New files.
* Makefile.in (mostlyclean_dirs): Add libexec, if its Makefile
exists.
* autogen.sh (do_git): Autoreconf in exec as well.
* configure.ac: Configure libexec on Android.
* exec/Makefile.in:
* exec/README:
* exec/config-mips.m4.in:
* exec/config.guess:
* exec/config.h.in:
* exec/config.sub:
* exec/configure:
* exec/configure.ac:
* exec/deps.mk:
* exec/exec.c (MIN, struct exec_open_command)
(struct exec_map_command, struct exec_jump_command)
(write_open_command, write_load_command, process_interpreter_1)
(process_interpreter, process_program_header, insert_args)
(exec_0):
* exec/exec.h (_EXEC_H_, struct elf_header_32)
(struct program_header_32, struct dt_entry_32)
(struct elf_header_64, struct program_header_64)
(struct dt_entry_64, struct exec_tracee):
* exec/exec1.c (main):
* exec/install-sh (scriptversion):
* 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):
* exec/mipsel-user.h (_MIPSEL_USER_H_):
* exec/mipsfpu.c (MIPS_ABI_FP_ANY, fpu_reqs, valid_abi_p)
(fp_mode_for_abi, cpu_supports_fr0_p, determine_fpu_mode):
* exec/mipsfpu.h (_MIPSFPU_H_, FP_FR0):
* exec/test.c (print_usage, main):
* exec/trace.c (MAX_TRACEES, aarch64_set_regs, read_memory)
(user_alloca, user_copy, remove_tracee, handle_clone)
(syscall_trap_p, handle_exec, process_system_call, tracing_execve)
(after_fork, find_tracee, exec_waitpid, exec_init): New files.
* java/Makefile.in (CROSS_EXEC_BINS): Add exec1 and
loader.
($(CROSS_EXEC_BINS) &): New target.
2023-04-30 21:37:19 +08:00