aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2016-05-16 09:33:03 +0100
committerRon Yorston <rmy@pobox.com>2016-05-16 09:33:03 +0100
commit35d2f5bccb0f3dde600702ebcdb5424d4d50be4a (patch)
tree6e0ff0341c69839e268459a199682628bae734ed /libbb
parent248a2600a2f4b442101ad568d1994b908bb28d4b (diff)
parentf2559e5c2b7bd2c5fa0dd8e88d0a931da92a23af (diff)
downloadbusybox-w32-35d2f5bccb0f3dde600702ebcdb5424d4d50be4a.tar.gz
busybox-w32-35d2f5bccb0f3dde600702ebcdb5424d4d50be4a.tar.bz2
busybox-w32-35d2f5bccb0f3dde600702ebcdb5424d4d50be4a.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'libbb')
-rw-r--r--libbb/appletlib.c3
-rw-r--r--libbb/common_bufsiz.c74
-rw-r--r--libbb/lineedit.c7
-rw-r--r--libbb/messages.c5
-rw-r--r--libbb/mode_string.c4
-rw-r--r--libbb/pw_encrypt.c2
-rw-r--r--libbb/u_signal_names.c2
7 files changed, 83 insertions, 14 deletions
diff --git a/libbb/appletlib.c b/libbb/appletlib.c
index 4a9d363dd..c528c8a2c 100644
--- a/libbb/appletlib.c
+++ b/libbb/appletlib.c
@@ -835,7 +835,8 @@ static int busybox_main(char **argv)
835 full_write2_str(a); 835 full_write2_str(a);
836 full_write2_str("\n"); 836 full_write2_str("\n");
837 i++; 837 i++;
838 a += strlen(a) + 1; 838 while (*a++ != '\0')
839 continue;
839 } 840 }
840 return 0; 841 return 0;
841 } 842 }
diff --git a/libbb/common_bufsiz.c b/libbb/common_bufsiz.c
new file mode 100644
index 000000000..1a3585169
--- /dev/null
+++ b/libbb/common_bufsiz.c
@@ -0,0 +1,74 @@
1/* vi: set sw=4 ts=4: */
2/*
3 * Utility routines.
4 *
5 * Copyright (C) 2016 Denys Vlasenko
6 *
7 * Licensed under GPLv2, see file LICENSE in this source tree.
8 */
9//config:config FEATURE_USE_BSS_TAIL
10//config: bool "Use the end of BSS page"
11//config: default n
12//config: help
13//config: Attempt to reclaim a small unused part of BSS.
14//config:
15//config: Executables have the following parts:
16//config: = read-only executable code and constants, also known as "text"
17//config: = read-write data
18//config: = non-initialized (zeroed on demand) data, also known as "bss"
19//config:
20//config: At link time, "text" is padded to a full page. At runtime, all "text"
21//config: pages are mapped RO and executable.
22//config: "Data" starts on the next page boundary, but is not padded
23//config: to a full page at the end. "Bss" starts wherever "data" ends.
24//config: At runtime, "data" pages are mapped RW and they are file-backed
25//config: (this includes a small portion of "bss" which may live in the last
26//config: partial page of "data").
27//config: Pages which are fully in "bss" are mapped to anonymous memory.
28//config:
29//config: "Bss" end is usually not page-aligned. There is an unused space
30//config: in the last page. Linker marks its start with the "_end" symbol.
31//config:
32//config: This option will attempt to use that space for bb_common_bufsiz1[]
33//config: array. If it fits after _end, it will be used, and COMMON_BUFSIZE
34//config: will be enlarged from its guaranteed minimum size of 1 kbyte.
35//config: This may require recompilation a second time, since value of _end
36//config: is known only after final link.
37//config:
38//config: If you are getting a build error like this:
39//config: appletlib.c:(.text.main+0xd): undefined reference to '_end'
40//config: disable this option.
41
42//kbuild:lib-y += common_bufsiz.o
43
44#include "libbb.h"
45#include "common_bufsiz.h"
46
47#if !ENABLE_FEATURE_USE_BSS_TAIL
48
49/* We use it for "global" data via *(struct global*)bb_common_bufsiz1.
50 * Since gcc insists on aligning struct global's members, it would be a pity
51 * (and an alignment fault on some CPUs) to mess it up. */
52char bb_common_bufsiz1[COMMON_BUFSIZE] ALIGNED(sizeof(long long));
53
54#else
55
56# ifndef setup_common_bufsiz
57/*
58 * It is not defined as a dummy macro.
59 * It means we have to provide this function.
60 */
61char *const bb_common_bufsiz1 __attribute__ ((section (".data")));
62void setup_common_bufsiz(void)
63{
64 if (!bb_common_bufsiz1)
65 *(char**)&bb_common_bufsiz1 = xzalloc(COMMON_BUFSIZE);
66}
67# else
68# ifndef bb_common_bufsiz1
69 /* bb_common_bufsiz1[] is not aliased to _end[] */
70char bb_common_bufsiz1[COMMON_BUFSIZE] ALIGNED(sizeof(long long));
71# endif
72# endif
73
74#endif
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index e7b9ddfa1..6c91f1794 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -829,12 +829,11 @@ static NOINLINE unsigned complete_cmd_dir_file(const char *command, int type)
829 if (type == FIND_EXE_ONLY) { 829 if (type == FIND_EXE_ONLY) {
830 const char *p = applet_names; 830 const char *p = applet_names;
831 831
832 i = 0; 832 while (*p) {
833 while (i < NUM_APPLETS) {
834 if (strncmp(pfind, p, pf_len) == 0) 833 if (strncmp(pfind, p, pf_len) == 0)
835 add_match(xstrdup(p)); 834 add_match(xstrdup(p));
836 p += strlen(p) + 1; 835 while (*p++ != '\0')
837 i++; 836 continue;
838 } 837 }
839 } 838 }
840#endif 839#endif
diff --git a/libbb/messages.c b/libbb/messages.c
index 2aa3f175d..d74c237e7 100644
--- a/libbb/messages.c
+++ b/libbb/messages.c
@@ -61,8 +61,3 @@ const char bb_path_wtmp_file[] ALIGN1 =
61# error unknown path to wtmp file 61# error unknown path to wtmp file
62# endif 62# endif
63#endif 63#endif
64
65/* We use it for "global" data via *(struct global*)&bb_common_bufsiz1.
66 * Since gcc insists on aligning struct global's members, it would be a pity
67 * (and an alignment fault on some CPUs) to mess it up. */
68char bb_common_bufsiz1[COMMON_BUFSIZE] ALIGNED(sizeof(long long));
diff --git a/libbb/mode_string.c b/libbb/mode_string.c
index f1afe7d61..934eb6dc7 100644
--- a/libbb/mode_string.c
+++ b/libbb/mode_string.c
@@ -87,9 +87,9 @@ const char* FAST_FUNC bb_mode_string(mode_t mode)
87 87
88/* The previous version used "0pcCd?bB-?l?s???". However, the '0', 'C', 88/* The previous version used "0pcCd?bB-?l?s???". However, the '0', 'C',
89 * and 'B' types don't appear to be available on linux. So I removed them. */ 89 * and 'B' types don't appear to be available on linux. So I removed them. */
90static const char type_chars[16] = "?pc?d?b?-?l?s???"; 90static const char type_chars[16] ALIGN1 = "?pc?d?b?-?l?s???";
91/********************************** 0123456789abcdef */ 91/********************************** 0123456789abcdef */
92static const char mode_chars[7] = "rwxSTst"; 92static const char mode_chars[7] ALIGN1 = "rwxSTst";
93 93
94const char* FAST_FUNC bb_mode_string(mode_t mode) 94const char* FAST_FUNC bb_mode_string(mode_t mode)
95{ 95{
diff --git a/libbb/pw_encrypt.c b/libbb/pw_encrypt.c
index dbc15e5fc..4cdc2de76 100644
--- a/libbb/pw_encrypt.c
+++ b/libbb/pw_encrypt.c
@@ -9,7 +9,7 @@
9 9
10#include "libbb.h" 10#include "libbb.h"
11 11
12/* static const uint8_t ascii64[] = 12/* static const uint8_t ascii64[] ALIGN1 =
13 * "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 13 * "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
14 */ 14 */
15 15
diff --git a/libbb/u_signal_names.c b/libbb/u_signal_names.c
index 8c78f5e20..b49714f2a 100644
--- a/libbb/u_signal_names.c
+++ b/libbb/u_signal_names.c
@@ -19,7 +19,7 @@
19/* Believe it or not, but some arches have more than 32 SIGs! 19/* Believe it or not, but some arches have more than 32 SIGs!
20 * HPPA: SIGSTKFLT == 36. */ 20 * HPPA: SIGSTKFLT == 36. */
21 21
22static const char signals[][7] = { 22static const char signals[][7] ALIGN1 = {
23 // SUSv3 says kill must support these, and specifies the numerical values, 23 // SUSv3 says kill must support these, and specifies the numerical values,
24 // http://www.opengroup.org/onlinepubs/009695399/utilities/kill.html 24 // http://www.opengroup.org/onlinepubs/009695399/utilities/kill.html
25 // {0, "EXIT"}, {1, "HUP"}, {2, "INT"}, {3, "QUIT"}, 25 // {0, "EXIT"}, {1, "HUP"}, {2, "INT"}, {3, "QUIT"},