* etc/NEWS: Update correspondingly.
* exec/Makefile.in (config-mips.m4): Don't define rule
or predicate $(LOADOBJS) on it elsewhere than on MIPS.
* exec/README: Direct developers to GDB.
* exec/trace.c (finish_exec): Resume the tracee after reporting
an error in `exec'.
(after_fork): If seccomp is enabled on Android, and the kernel
is 4.7 or earlier, detect whether revisions to the sequencing of
seccomp events have been backported from 4.8.
(exec_waitpid): Resume the process with PTRACE_CONT after
receiving an unknown signal.
(exec_init): Cease disabling seccomp on Android kernels earlier
than 4.8.
* exec/configure.ac (REENTRANT): Remove option for reentrancy.
(PROGRAM_COUNTER, HAVE_SECCOMP): Define register providing the
program counter and enable seccomp if its headers are available.
* exec/exec.c (write_load_command): Avoid defining unused
variable.
(exec_0): Remove code specific to REENTRANT configurations.
* exec/exec.h (struct exec_tracee) <exec_data, data_size>: New
fields for loader instructions and their size.
* exec/exec1.c (main): Call exec_init before forking.
* exec/mipsel-user.h (ELF_NGREG): Delete definition.
(struct mipsel_regs): Reduce number of gregs to 32, but
introduce separate fields for special registers.
* exec/trace.c (use_seccomp_p): New variable; defile to false if
!HAVE_SECCOMP.
(remove_tracee): Cease providing for non-reentrant
configurations. Release executable data if present.
(handle_clone_prepare): Likewise. Resume process with
PTRACE_CONT if seccomp-based interception is enabled.
(handle_clone, check_signal): Resume processes as above.
(handle_exec): Divide into two functions, with only rewriting
the system call and generating instructions for the loader
remaining in the first, and copying such instructions into the
loader's stack removed into a new function, `finish_exec'.
(finish_exec): New function.
(handle_readlinkat, handle_openat): Abolish non-REENTRANT
configurations.
(process_system_call): Divide exec system calls into two phases,
disambiguated by the value of tracee->waiting_for_syscall. Typo
fixes. Accommodate syscall-exit-stops where the signal was
initially intercepted by `seccomp_system_call'.
(interesting_syscalls): New array.
(ARRAYELTS): New macro.
(seccomp_system_call, establish_seccomp_filter): New function.
(tracing_execve) [HAVE_SECCOMP]: Establish a seccomp filter if
this is to be enabled.
(after_fork): Provide PTRACE_O_TRACESECCOMP. Resume process
with PTRACE_CONT if seccomp-based interception is enabled.
(exec_waitpid): Resume process with PTRACE_CONT if seccomp-based
interception is enabled. Dispatch stops identifying as
PTRACE_EVENT_SECCOMP to `seccomp_system_call'.
(exec_init): Establish whether it is possible to enable seccomp.
* exec/Makefile.in (is_mips): New substitution.
(.s.o): Avoid calling m4 unless it be set.
* exec/configure.ac: Substitute is_mips, and don't generate
config-mips.m4 otherwise.
* exec/loader-x86.s:
* exec/loader-x86_64.s: Use assembler rather than m4-defined
comment syntax.
* 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.
* 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.
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.
* exec/loader-armeabi.s (timespec):
* exec/loader-mips64el.s (__start):
* exec/loader-mipsel.s (__start): Use ?c instead of integer in local
variables.
* 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>.
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.
* 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.
* 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.
* exec/trace.c (check_signal): New function.
(handle_exec, process_system_call): Handle signal-delivery-stop
while waiting synchronously for syscall completion.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.
* 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.