diff options
| author | Po Lu | 2025-04-13 18:50:59 +0800 |
|---|---|---|
| committer | Po Lu | 2025-04-13 18:51:49 +0800 |
| commit | 7a01350624e1665e707f98e13d51f53e9f87ce95 (patch) | |
| tree | 589f2a612bc44670eeec8ec77ae9ed9f81df0c25 /exec/exec.c | |
| parent | f5b59a8a7318d611a04ef32f4042e3ca9bd1b315 (diff) | |
| download | emacs-7a01350624e1665e707f98e13d51f53e9f87ce95.tar.gz emacs-7a01350624e1665e707f98e13d51f53e9f87ce95.zip | |
Replace AT_EXECFN in auxiliary vectors of programs executed on Android
* exec/exec.c (insert_args, exec_0): On non-MIPS systems, copy
NAME and its length to the loader area. State that MIPS support
is not yet available (though it will be pending the availability
of a functioning emulator).
* exec/loader-aarch64.s (_start):
* exec/loader-armeabi.s (_start):
* exec/loader-x86.s (_start):
* exec/loader-x86_64.s (_start): Displace auxv, environ, and
argv to create sufficient space for the provided file name, and
copy the file name there. Replace AT_EXECFN to refer to this
space.
Diffstat (limited to 'exec/exec.c')
| -rw-r--r-- | exec/exec.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/exec/exec.c b/exec/exec.c index b1c9825daff..7a8ef2c3a1a 100644 --- a/exec/exec.c +++ b/exec/exec.c | |||
| @@ -831,7 +831,7 @@ insert_args (struct exec_tracee *tracee, USER_REGS_STRUCT *regs, | |||
| 831 | assert (new3 == new + effective_size); | 831 | assert (new3 == new + effective_size); |
| 832 | 832 | ||
| 833 | /* And that it is properly aligned. */ | 833 | /* And that it is properly aligned. */ |
| 834 | assert (!(new3 & (sizeof new3 - 2))); | 834 | assert (!(new3 & (sizeof new3 - 1))); |
| 835 | 835 | ||
| 836 | /* Now modify the system call argument to point to new + | 836 | /* Now modify the system call argument to point to new + |
| 837 | text_size. */ | 837 | text_size. */ |
| @@ -916,6 +916,9 @@ exec_0 (char *name, struct exec_tracee *tracee, | |||
| 916 | program_header program; | 916 | program_header program; |
| 917 | USER_WORD entry, program_entry, offset; | 917 | USER_WORD entry, program_entry, offset; |
| 918 | USER_WORD header_offset; | 918 | USER_WORD header_offset; |
| 919 | #ifndef __mips__ | ||
| 920 | USER_WORD name_len, aligned_len; | ||
| 921 | #endif /* !__mips__ */ | ||
| 919 | struct exec_jump_command jump; | 922 | struct exec_jump_command jump; |
| 920 | #if defined __mips__ && !defined MIPS_NABI | 923 | #if defined __mips__ && !defined MIPS_NABI |
| 921 | int fpu_mode; | 924 | int fpu_mode; |
| @@ -1146,6 +1149,26 @@ exec_0 (char *name, struct exec_tracee *tracee, | |||
| 1146 | sizeof jump); | 1149 | sizeof jump); |
| 1147 | loader_area_used += sizeof jump; | 1150 | loader_area_used += sizeof jump; |
| 1148 | 1151 | ||
| 1152 | /* TODO: MIPS support. */ | ||
| 1153 | #ifndef __mips__ | ||
| 1154 | /* Copy the length of NAME and NAME itself to the loader area. */ | ||
| 1155 | name_len = strlen (name); | ||
| 1156 | aligned_len = ((name_len + 1 + sizeof name_len - 1) | ||
| 1157 | & -sizeof name_len); | ||
| 1158 | if (sizeof loader_area - loader_area_used | ||
| 1159 | < aligned_len + sizeof name_len) | ||
| 1160 | goto fail1; | ||
| 1161 | memcpy (loader_area + loader_area_used, &name_len, sizeof name_len); | ||
| 1162 | loader_area_used += sizeof name_len; | ||
| 1163 | memcpy (loader_area + loader_area_used, name, name_len + 1); | ||
| 1164 | loader_area_used += name_len + 1; | ||
| 1165 | |||
| 1166 | /* Properly align the loader area. */ | ||
| 1167 | offset = aligned_len - (name_len + 1); | ||
| 1168 | while (offset--) | ||
| 1169 | loader_area[loader_area_used++] = '\0'; | ||
| 1170 | #endif /* !__mips__ */ | ||
| 1171 | |||
| 1149 | /* Close the file descriptor and return the number of bytes | 1172 | /* Close the file descriptor and return the number of bytes |
| 1150 | used. */ | 1173 | used. */ |
| 1151 | 1174 | ||