Browse Source
asm volatile("":::"memory") doesn't work reliably, so it is better to disable optimization for whole function where INIT_G() or similar is used to avoid instruction reordering. Covers following issues: * https://github.com/termux/termux-packages/issues/2488 * https://github.com/termux/termux-packages/issues/3216emacs-27
Leonid Plyushch
5 years ago
2 changed files with 49 additions and 68 deletions
@ -1,76 +1,56 @@ |
|||||
diff -uNr busybox-1.31.1/miscutils/less.c busybox-1.31.1.mod/miscutils/less.c
|
diff -uNr busybox-1.31.1/miscutils/less.c busybox-1.31.1.mod/miscutils/less.c
|
||||
--- busybox-1.31.1/miscutils/less.c 2019-06-10 13:50:53.000000000 +0300
|
--- busybox-1.31.1/miscutils/less.c 2019-06-10 13:50:53.000000000 +0300
|
||||
+++ busybox-1.31.1.mod/miscutils/less.c 2019-11-11 21:31:58.406733857 +0200
|
+++ busybox-1.31.1.mod/miscutils/less.c 2019-11-12 03:30:59.054944977 +0200
|
||||
@@ -278,6 +278,7 @@
|
@@ -1803,6 +1803,7 @@
|
||||
#define kbd_input (G.kbd_input ) |
} |
||||
#define INIT_G() do { \ |
#endif |
||||
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ |
|
||||
+ asm volatile("":::"memory"); \
|
+#pragma clang optimize off
|
||||
less_gets_pos = -1; \ |
int less_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
||||
empty_line_marker = "~"; \ |
int less_main(int argc, char **argv) |
||||
current_file = 1; \ |
{ |
||||
|
diff -uNr busybox-1.31.1/networking/ftpd.c busybox-1.31.1.mod/networking/ftpd.c
|
||||
|
--- busybox-1.31.1/networking/ftpd.c 2019-06-10 13:50:53.000000000 +0300
|
||||
|
+++ busybox-1.31.1.mod/networking/ftpd.c 2019-11-12 04:05:11.739983958 +0200
|
||||
|
@@ -1169,6 +1169,7 @@
|
||||
|
OPT_w = (1 << (BIT_A + 3)) * ENABLE_FEATURE_FTPD_WRITE, |
||||
|
}; |
||||
|
|
||||
|
+#pragma clang optimize off
|
||||
|
int ftpd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
||||
|
int ftpd_main(int argc UNUSED_PARAM, char **argv) |
||||
|
{ |
||||
diff -uNr busybox-1.31.1/networking/httpd.c busybox-1.31.1.mod/networking/httpd.c
|
diff -uNr busybox-1.31.1/networking/httpd.c busybox-1.31.1.mod/networking/httpd.c
|
||||
--- busybox-1.31.1/networking/httpd.c 2019-06-10 13:50:53.000000000 +0300
|
--- busybox-1.31.1/networking/httpd.c 2019-06-10 13:50:53.000000000 +0300
|
||||
+++ busybox-1.31.1.mod/networking/httpd.c 2019-11-11 21:31:58.406733857 +0200
|
+++ busybox-1.31.1.mod/networking/httpd.c 2019-11-12 03:30:08.104709323 +0200
|
||||
@@ -485,6 +485,7 @@
|
@@ -2663,7 +2663,7 @@
|
||||
#define INIT_G() do { \ |
OPT_VERBOSE = 1 << p_opt_verbose, |
||||
setup_common_bufsiz(); \ |
}; |
||||
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ |
|
||||
+ asm volatile("":::"memory"); \
|
-
|
||||
IF_FEATURE_HTTPD_BASIC_AUTH(g_realm = "Web Server Authentication";) \ |
+#pragma clang optimize off
|
||||
IF_FEATURE_HTTPD_RANGES(range_start = -1;) \ |
int httpd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
||||
bind_addr_or_port = "80"; \ |
int httpd_main(int argc UNUSED_PARAM, char **argv) |
||||
|
{ |
||||
diff -uNr busybox-1.31.1/runit/svlogd.c busybox-1.31.1.mod/runit/svlogd.c
|
diff -uNr busybox-1.31.1/runit/svlogd.c busybox-1.31.1.mod/runit/svlogd.c
|
||||
--- busybox-1.31.1/runit/svlogd.c 2019-06-10 13:50:53.000000000 +0300
|
--- busybox-1.31.1/runit/svlogd.c 2019-06-10 13:50:53.000000000 +0300
|
||||
+++ busybox-1.31.1.mod/runit/svlogd.c 2019-11-11 21:31:58.406733857 +0200
|
+++ busybox-1.31.1.mod/runit/svlogd.c 2019-11-12 03:28:11.214155815 +0200
|
||||
@@ -244,6 +244,7 @@
|
@@ -1034,6 +1034,7 @@
|
||||
#define INIT_G() do { \ |
} |
||||
setup_common_bufsiz(); \ |
} |
||||
SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ |
|
||||
+ asm volatile("":::"memory"); \
|
+#pragma clang optimize off
|
||||
linemax = 1000; \ |
int svlogd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
||||
/*buflen = 1024;*/ \ |
int svlogd_main(int argc, char **argv) |
||||
linecomplete = 1; \ |
{ |
||||
diff -uNr busybox-1.31.1/shell/ash.c busybox-1.31.1.mod/shell/ash.c
|
diff -uNr busybox-1.31.1/shell/ash.c busybox-1.31.1.mod/shell/ash.c
|
||||
--- busybox-1.31.1/shell/ash.c 2019-10-21 17:54:40.000000000 +0300
|
--- busybox-1.31.1/shell/ash.c 2019-10-21 17:54:40.000000000 +0300
|
||||
+++ busybox-1.31.1.mod/shell/ash.c 2019-11-11 21:31:58.410067203 +0200
|
+++ busybox-1.31.1.mod/shell/ash.c 2019-11-12 03:24:39.613095056 +0200
|
||||
@@ -490,6 +490,7 @@
|
@@ -14278,6 +14278,7 @@
|
||||
#define backgndpid (G_misc.backgndpid ) |
* exception occurs. When an exception occurs the variable "state" |
||||
#define INIT_G_misc() do { \ |
* is used to figure out how far we had gotten. |
||||
(*(struct globals_misc**)&ash_ptr_to_globals_misc) = xzalloc(sizeof(G_misc)); \ |
*/ |
||||
+ asm volatile("":::"memory"); \
|
+#pragma clang optimize off
|
||||
barrier(); \ |
int ash_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
||||
curdir = nullstr; \ |
#if NUM_SCRIPTS > 0 |
||||
physdir = nullstr; \ |
int ash_main(int argc, char **argv) |
||||
@@ -1543,6 +1544,7 @@
|
|
||||
#define stackbase (G_memstack.stackbase ) |
|
||||
#define INIT_G_memstack() do { \ |
|
||||
(*(struct globals_memstack**)&ash_ptr_to_globals_memstack) = xzalloc(sizeof(G_memstack)); \ |
|
||||
+ asm volatile("":::"memory"); \
|
|
||||
barrier(); \ |
|
||||
g_stackp = &stackbase; \ |
|
||||
g_stacknxt = stackbase.space; \ |
|
||||
@@ -2166,6 +2168,7 @@
|
|
||||
#define INIT_G_var() do { \ |
|
||||
unsigned i; \ |
|
||||
(*(struct globals_var**)&ash_ptr_to_globals_var) = xzalloc(sizeof(G_var)); \ |
|
||||
+ asm volatile("":::"memory"); \
|
|
||||
barrier(); \ |
|
||||
for (i = 0; i < ARRAY_SIZE(varinit_data); i++) { \ |
|
||||
varinit[i].flags = varinit_data[i].flags; \ |
|
||||
@@ -3348,6 +3351,7 @@
|
|
||||
|
|
||||
static struct alias **atab; // [ATABSIZE]; |
|
||||
#define INIT_G_alias() do { \ |
|
||||
+ asm volatile("":::"memory"); \
|
|
||||
atab = xzalloc(ATABSIZE * sizeof(atab[0])); \ |
|
||||
} while (0) |
|
||||
|
|
||||
@@ -8073,6 +8077,7 @@
|
|
||||
|
|
||||
static struct tblentry **cmdtable; |
|
||||
#define INIT_G_cmdtable() do { \ |
|
||||
+ asm volatile("":::"memory"); \
|
|
||||
cmdtable = xzalloc(CMDTABLESIZE * sizeof(cmdtable[0])); \ |
|
||||
} while (0) |
|
||||
|
|
||||
|
Loading…
Reference in new issue