*: remove remaining instances of ".data" hack
diff --git a/libbb/Kbuild b/libbb/Kbuild
index 3a68efc..d943628 100644
--- a/libbb/Kbuild
+++ b/libbb/Kbuild
@@ -50,7 +50,7 @@
lib-y += isdirectory.o
lib-y += kernel_version.o
lib-y += last_char_is.o
-lib-y += lineedit.o
+lib-y += lineedit.o lineedit_ptr_hack.o
lib-y += llist.o
lib-y += login.o
lib-y += make_directory.o
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index ed7d391..90fca8c 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -177,11 +177,6 @@
}
-#ifdef __GLIBC__
-/* Make it reside in R/W memory: */
-int *const bb_errno __attribute__ ((section (".data")));
-#endif
-
void lbb_prepare(const char *applet
USE_FEATURE_INDIVIDUAL(, char **argv))
MAIN_EXTERNALLY_VISIBLE;
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index 4ba61c1..6de66ba 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -74,7 +74,7 @@
#endif
/* We try to minimize both static and stack usage. */
-struct statics {
+struct lineedit_statics {
line_input_t *state;
volatile unsigned cmdedit_termw; /* = 80; */ /* actual terminal width */
@@ -120,11 +120,10 @@
#endif
};
-/* Make it reside in writable memory, yet make compiler understand
- * that it is not going to change. */
-static struct statics *const ptr_to_statics __attribute__ ((section (".data")));
+/* See lineedit_ptr_hack.c */
+extern struct lineedit_statics *const lineedit_ptr_to_statics;
-#define S (*ptr_to_statics)
+#define S (*lineedit_ptr_to_statics)
#define state (S.state )
#define cmdedit_termw (S.cmdedit_termw )
#define previous_SIGWINCH_handler (S.previous_SIGWINCH_handler)
@@ -145,7 +144,7 @@
#define delbuf (S.delbuf )
#define INIT_S() do { \
- (*(struct statics**)&ptr_to_statics) = xzalloc(sizeof(S)); \
+ (*(struct lineedit_statics**)&lineedit_ptr_to_statics) = xzalloc(sizeof(S)); \
barrier(); \
cmdedit_termw = 80; \
USE_FEATURE_EDITING_FANCY_PROMPT(num_ok_lines = 1;) \
@@ -163,7 +162,7 @@
if (home_pwd_buf != null_str)
free(home_pwd_buf);
#endif
- free(ptr_to_statics);
+ free(lineedit_ptr_to_statics);
}
#define DEINIT_S() deinit_S()
diff --git a/libbb/ptr_to_globals.c b/libbb/ptr_to_globals.c
index 48cf8d8..5f30e2a 100644
--- a/libbb/ptr_to_globals.c
+++ b/libbb/ptr_to_globals.c
@@ -5,6 +5,8 @@
* Licensed under GPLv2, see file LICENSE in this tarball for details.
*/
+#include <errno.h>
+
struct globals;
#ifndef GCC_COMBINE
@@ -13,12 +15,21 @@
* but here we make it live in R/W memory */
struct globals *ptr_to_globals;
+#ifdef __GLIBC__
+int *bb_errno;
+#endif
+
+
#else
+
/* gcc -combine will see through and complain */
/* Using alternative method which is more likely to break
* on weird architectures, compilers, linkers and so on */
struct globals *const ptr_to_globals __attribute__ ((section (".data")));
+#ifdef __GLIBC__
+int *const bb_errno __attribute__ ((section (".data")));
#endif
+#endif