diff options
author | Po Lu <luangruo@yahoo.com> | 2023-05-01 11:28:22 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2023-05-01 11:28:22 +0800 |
commit | ddc16de86964d445309dd38175a85221c14f05ab (patch) | |
tree | 42b7b7d86abd636e90dbc914f347b32b7099ef33 /exec | |
parent | a8f9a4d2d9bc982217b4be783b236778f9d6dd32 (diff) | |
download | emacs-ddc16de86964d445309dd38175a85221c14f05ab.tar.gz |
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.
Diffstat (limited to 'exec')
-rw-r--r-- | exec/Makefile.in | 6 | ||||
-rw-r--r-- | exec/config-mips.m4.in | 6 | ||||
-rw-r--r-- | exec/configure.ac | 70 | ||||
-rw-r--r-- | exec/exec.c | 2 | ||||
-rw-r--r-- | exec/loader-mips64el.s | 45 | ||||
-rw-r--r-- | exec/mipsel-user.h | 1 |
6 files changed, 95 insertions, 35 deletions
diff --git a/exec/Makefile.in b/exec/Makefile.in index 5bd61b2e831..365dc42e0b7 100644 --- a/exec/Makefile.in +++ b/exec/Makefile.in @@ -81,10 +81,10 @@ Makefile: config.status Makefile.in .SUFFIXES: .c .s .c.o: - $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEPFLAGS) -I$(srcdir) $< -o $@ + $(CC) -c $(CPPFLAGS) $(CFLAGS) $(DEPFLAGS) -I$(srcdir) -I. $< -o $@ .s.o: - $(M4) $< > $<.s - $(AS) $(ASFLAGS) $<.s -o $@ + $(M4) $< > $(notdir $<).s + $(AS) $(ASFLAGS) $(notdir $<).s -o $@ # Set up dependencies for config-mips.m4. diff --git a/exec/config-mips.m4.in b/exec/config-mips.m4.in index 886d19b8e8f..72632765bd0 100644 --- a/exec/config-mips.m4.in +++ b/exec/config-mips.m4.in @@ -34,3 +34,9 @@ define(`SYSCALL', `ifelse(`@MIPS_N32@',`yes',` move $a4, $1 sw $4, 28($sp)')') define(`RESTORE', `ifelse(`@MIPS_N32@',`yes',` nop',` addi $sp, 32')') + +dnl For mips64. Some assemblers don't want to assemble `daddi'. +define(`DADDI2', `ifelse(`@DADDI_BROKEN@',`yes',` li $at, $2 +dadd $1, $1, $at',` daddi $1, $2')') +define(`DADDI3', `ifelse(`@DADDI_BROKEN@',`yes',` li $at, $3 +dadd $1, $2, $at',` daddi $1, $2, $3')') diff --git a/exec/configure.ac b/exec/configure.ac index 0a334c6e4ff..9763edc99f3 100644 --- a/exec/configure.ac +++ b/exec/configure.ac @@ -96,6 +96,13 @@ AH_TEMPLATE([CLONE3_SYSCALL], [Define to number of the `clone3' system call.]) AC_CANONICAL_HOST +# Check whether or not sys/user exists. If it doesn't, try +# asm/user.h, and croak if that doesn't exist either. +AS_CASE([$host], [*mips*], [], [*], + [AC_CHECK_HEADER([sys/user.h], [user_h="<sys/user.h>"], + [AC_CHECK_HEADER([asm/user.h], [user_h="<asm/user.h>"], + [AC_MSG_ERROR([Can not find working user.h])])])]) + # Look for required tools. AC_ARG_VAR([M4], [`m4' preprocessor command.]) @@ -187,11 +194,12 @@ AS_IF([test "x$exec_cv_mips_nabi" != "xno"], exec_loader= is_mips= OBJS="exec.o trace.o" +DADDI_BROKEN=no AS_CASE([$host], [x86_64-*linux*], [AC_CHECK_MEMBER([struct user_regs_struct.rdi], [AC_DEFINE([SYSCALL_HEADER], [<asm/unistd.h>]) - AC_DEFINE([USER_HEADER], [<sys/user.h>]) + AC_DEFINE_UNQUOTED([USER_HEADER], [$user_h]) AC_DEFINE([USER_REGS_STRUCT], [struct user_regs_struct]) AC_DEFINE([SYSCALL_NUM_REG], [orig_rax]) AC_DEFINE([SYSCALL_RET_REG], [rax]) @@ -213,11 +221,11 @@ AS_CASE([$host], [x86_64-*linux*], exec_loader=loader-x86_64.s], [AC_MSG_ERROR([Missing `rdi' in user_regs_struct])], [[ -#include <sys/user.h> +#include $user_h ]])], [i[[34567]]86-*linux*], [AC_CHECK_MEMBER([struct user_regs_struct.edi], [AC_DEFINE([SYSCALL_HEADER], [<asm/unistd.h>]) - AC_DEFINE([USER_HEADER], [<sys/user.h>]) + AC_DEFINE_UNQUOTED([USER_HEADER], [$user_h]) AC_DEFINE([USER_REGS_STRUCT], [struct user_regs_struct]) AC_DEFINE([SYSCALL_NUM_REG], [orig_eax]) AC_DEFINE([SYSCALL_RET_REG], [eax]) @@ -237,11 +245,11 @@ AS_CASE([$host], [x86_64-*linux*], exec_loader=loader-x86.s], [AC_MSG_ERROR([Missing `edi' in user_regs_struct])], [[ -#include <sys/user.h> +#include $user_h ]])], [aarch64-*linux*], [AC_CHECK_MEMBER([struct user_regs_struct.sp], [AC_DEFINE([SYSCALL_HEADER], [<asm/unistd.h>]) - AC_DEFINE([USER_HEADER], [<sys/user.h>]) + AC_DEFINE_UNQUOTED([USER_HEADER], [$user_h]) AC_DEFINE([USER_REGS_STRUCT], [struct user_regs_struct]) AC_DEFINE([SYSCALL_NUM_REG], [[regs[8]]]) AC_DEFINE([SYSCALL_RET_REG], [[regs[0]]]) @@ -263,11 +271,11 @@ AS_CASE([$host], [x86_64-*linux*], exec_loader=loader-aarch64.s], [AC_MSG_ERROR([Missing `sp' in user_regs_struct])], [[ -#include <sys/user.h> +#include $user_h ]])], [arm*linux*eabi* | armv7*linux*], [AC_CHECK_MEMBER([struct user_regs.uregs], [AC_DEFINE([SYSCALL_HEADER], [<asm/unistd.h>]) - AC_DEFINE([USER_HEADER], [<sys/user.h>]) + AC_DEFINE_UNQUOTED([USER_HEADER], [$user_h]) AC_DEFINE([USER_REGS_STRUCT], [struct user_regs]) AC_DEFINE([SYSCALL_NUM_REG], [[uregs[7]]]) AC_DEFINE([SYSCALL_RET_REG], [[uregs[0]]]) @@ -283,9 +291,30 @@ AS_CASE([$host], [x86_64-*linux*], exec_CHECK_LINUX_CLONE3 LOADERFLAGS="$LOADERFLAGS $LDPREFIX-Ttext=0x20000000" exec_loader=loader-armeabi.s], - [AC_MSG_ERROR([Missing `uregs' in user_regs_struct])], + [AC_CHECK_MEMBER([struct pt_regs.uregs], + [AC_DEFINE([SYSCALL_HEADER], [<asm/unistd.h>]) + AC_DEFINE_UNQUOTED([USER_HEADER], [<asm/ptrace.h>]) + AC_DEFINE([USER_REGS_STRUCT], [struct pt_regs]) + AC_DEFINE([SYSCALL_NUM_REG], [[uregs[7]]]) + AC_DEFINE([SYSCALL_RET_REG], [[uregs[0]]]) + AC_DEFINE([SYSCALL_ARG_REG], [[uregs[0]]]) + AC_DEFINE([SYSCALL_ARG1_REG], [[uregs[1]]]) + AC_DEFINE([STACK_POINTER], [[uregs[13]]]) + AC_DEFINE([EXEC_SYSCALL], [__NR_execve]) + AC_DEFINE([USER_WORD], [uintptr_t]) + AC_DEFINE([EXECUTABLE_BASE], [0x0f000000]) + AC_DEFINE([INTERPRETER_BASE], [0x1f000000]) + AC_DEFINE([STACK_GROWS_DOWNWARDS], [1]) + AC_DEFINE([CLONE_SYSCALL], [__NR_clone]) + exec_CHECK_LINUX_CLONE3 + LOADERFLAGS="$LOADERFLAGS $LDPREFIX-Ttext=0x20000000" + exec_loader=loader-armeabi.s], + [AC_MSG_ERROR([Missing `uregs' in user_regs_struct or pt_regs])], + [[ +#include <asm/ptrace.h> + ]])], [[ -#include <sys/user.h> +#include $user_h ]])], [mipsel*linux*], [AC_DEFINE([SYSCALL_HEADER], [<asm/unistd.h>]) AC_DEFINE([USER_HEADER], ["mipsel-user.h"]) @@ -325,6 +354,27 @@ AS_CASE([$host], [x86_64-*linux*], AC_DEFINE([INTERPRETER_BASE], [0x3f00000000]) AC_DEFINE([STACK_GROWS_DOWNWARDS], [1]) AC_DEFINE([CLONE_SYSCALL], [__NR_clone]) + AC_CACHE_CHECK([whether as understands `daddi'], + [exec_cv_as_daddi], + [exec_cv_as_daddi=no + cat <<_ACEOF >conftest.s + .section text + .global __start +__start: + li $t0, 0 + li $t1, 0 + daddi $t0, $t1, 1 + daddi $t0, $t1, -1 + daddi $t0, -1 + daddi $t0, 1 + +_ACEOF + $AS $ASFLAGS conftest.s -o conftest.$OBJEXT \ + >&AS_MESSAGE_LOG_FD 2>&1 \ + && exec_cv_as_daddi=yes + rm -f conftest.s conftest.$OBJEXT]) + AS_IF([test "x$exec_cv_as_daddi" != "xyes"], + [DADDI_BROKEN=yes]) exec_CHECK_LINUX_CLONE3 exec_CHECK_MIPS_NABI LOADERFLAGS="$LOADERFLAGS $LDPREFIX-Ttext=0x3e00000000" @@ -332,6 +382,8 @@ AS_CASE([$host], [x86_64-*linux*], exec_loader=loader-mips64el.s], [*], [AC_MSG_ERROR([Please port libexec to $host])]) +AC_SUBST([DADDI_BROKEN]) + MIPS_N32=$exec_cv_mips_nabi AC_ARG_VAR([LOADERFLAGS], [Flags used to link the loader.]) diff --git a/exec/exec.c b/exec/exec.c index e890179a9ab..662c8bf69d2 100644 --- a/exec/exec.c +++ b/exec/exec.c @@ -95,7 +95,7 @@ check_interpreter (const char *name, int fd, const char **extra) /* Strip leading whitespace. */ start = buffer; - while (*start && *start < 128 && isspace (*start)) + while (*start && ((unsigned char) *start) < 128 && isspace (*start)) ++start; /* Look for a newline character. */ diff --git a/exec/loader-mips64el.s b/exec/loader-mips64el.s index ccebdfe72f6..73dc8c63fe8 100644 --- a/exec/loader-mips64el.s +++ b/exec/loader-mips64el.s @@ -15,7 +15,10 @@ # You should have received a copy of the GNU General Public License # along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. +include(`config-mips.m4') + .set noreorder # delay slots managed by hand + .set noat # no assembler macros .section .text .global __start __start: @@ -24,8 +27,8 @@ dnl dla $a0, .timespec # rqtp dnl li $a1, 0 # rmtp dnl syscall # syscall ld $s2, ($sp) # original stack pointer - daddi $s0, $sp, 16 # start of load area - daddi $sp, -16 # primary fd, secondary fd + DADDI3( $s0, $sp, 16) # start of load area + DADDI2( $sp, -16) # primary fd, secondary fd li $t0, -1 # secondary fd sd $t0, 8($sp) # initialize secondary fd .next_action: @@ -33,7 +36,7 @@ dnl syscall # syscall andi $t0, $s1, 15 # t0 = action number & 15 beqz $t0, .open_file # open file? nop # delay slot - daddi $t0, -3 # t0 -= 3 + DADDI2( $t0, -3) # t0 -= 3 beqz $t0, .rest_of_exec # jump to code nop # delay slot li $t1, 1 @@ -76,30 +79,30 @@ dnl syscall # syscall bne $t2, $zero, .fillb # fill bytes nop # delay slot sd $zero, ($t1) # zero doubleword - daddi $t1, 8 # next doubleword + DADDI2( $t1, 8) # next doubleword sd $zero, ($t1) # zero doubleword - daddi $t1, 8 # next doubleword + DADDI2( $t1, 8) # next doubleword sd $zero, ($t1) # zero doubleword - daddi $t1, 8 # next doubleword + DADDI2( $t1, 8) # next doubleword sd $zero, ($t1) # zero doubleword - daddi $t1, 8 # next doubleword + DADDI2( $t1, 8) # next doubleword sd $zero, ($t1) # zero doubleword - daddi $t1, 8 # next doubleword + DADDI2( $t1, 8) # next doubleword sd $zero, ($t1) # zero doubleword - daddi $t1, 8 # next doubleword + DADDI2( $t1, 8) # next doubleword sd $zero, ($t1) # zero doubleword - daddi $t1, 8 # next doubleword + DADDI2( $t1, 8) # next doubleword sd $zero, ($t1) # zero doubleword - daddi $t1, 8 # next doubleword + DADDI2( $t1, 8) # next doubleword j .filld # fill either doubleword or byte nop # delay slot .fillb: beq $t0, $t1, .continue # already finished? nop # delay slot sb $zero, ($t1) # clear byte - daddi $t1, $t1, 1 # t1++ + DADDI2( $t1, 1) # t1++ .continue: - daddi $s0, $s0, 56 # s0 = next action + DADDI2( $s0, 56) # s0 = next action j .next_action # next action nop # delay slot .do_mmap_anon: @@ -113,26 +116,26 @@ dnl syscall # syscall nop # branch delay slot .open_file: li $v0, 5002 # SYS_open - daddi $a0, $s0, 8 # start of name + DADDI3( $a0, $s0, 8) # start of name move $a1, $zero # flags = O_RDONLY move $a2, $zero # mode = 0 syscall # syscall bne $a3, $zero, .perror # perror nop # delay slot - daddi $s0, $s0, 8 # start of string + DADDI2( $s0, 8) # start of string .nextc: lb $t0, ($s0) # load byte - daddi $s0, $s0, 1 # s0++ + DADDI2( $s0, 1) # s0++ bne $t0, $zero, .nextc # next character? nop # delay slot - daddi $s0, $s0, 7 # adjust for round + DADDI2( $s0, 7) # adjust for round li $t2, -8 # t2 = -8 and $s0, $s0, $t2 # mask for round andi $t0, $s1, 16 # t1 = s1 & 16 move $t1, $sp # address of primary fd beqz $t0, .primary # primary fd? nop # delay slot - daddi $t1, $t1, 8 # address of secondary fd + DADDI2( $t1, 8) # address of secondary fd .primary: sd $v0, ($t1) # store fd j .next_action # next action @@ -145,11 +148,11 @@ dnl syscall # syscall move $s1, $s2 # original SP ld $t0, ($s1) # argc dsll $t0, $t0, 3 # argc *= 3 - daddi $t0, $t0, 16 # argc += 16 + DADDI2( $t0, 16) # argc += 16 dadd $s1, $s1, $t0 # s1 = start of envp .skipenv: ld $t0, ($s1) # t0 = *s1 - daddi $s1, $s1, 8 # s1++ + DADDI2( $s1, 8) # s1++ bne $t0, $zero, .skipenv # skip again nop # delay slot dla $t3, .auxvtab # address of auxv table @@ -170,7 +173,7 @@ dnl syscall # syscall ld $t2, ($t2) # t2 = *t2 sd $t2, 8($s1) # set auxv value .next: - daddi $s1, $s1, 16 # next auxv + DADDI2( $s1, 16) # next auxv j .one_auxv # next auxv nop # delay slot .finish: diff --git a/exec/mipsel-user.h b/exec/mipsel-user.h index 2b77a970d8e..dc3f98eb4e7 100644 --- a/exec/mipsel-user.h +++ b/exec/mipsel-user.h @@ -22,7 +22,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ #ifndef _MIPSEL_USER_H_ #define _MIPSEL_USER_H_ -#include <sgidefs.h> #include <sys/user.h> #ifndef ELF_NGREG |