diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-29 03:31:20 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-11-29 03:31:20 +0000 |
commit | 745cd17926a9d75cdd6482d5ce58227b492d1ebe (patch) | |
tree | 568f3236704000eed61d3460f9eef92e9535b746 /applets/applet_tables.c | |
parent | c253778de92441b61806e1e4e7806e91f17ea50f (diff) | |
download | busybox-w32-745cd17926a9d75cdd6482d5ce58227b492d1ebe.tar.gz busybox-w32-745cd17926a9d75cdd6482d5ce58227b492d1ebe.tar.bz2 busybox-w32-745cd17926a9d75cdd6482d5ce58227b492d1ebe.zip |
Further optimize applet tables; prettify build output
text data bss dec hex filename
775923 929 9100 785952 bfe20 busybox_old
775565 929 9100 785594 bfcba busybox_unstripped
Diffstat (limited to 'applets/applet_tables.c')
-rw-r--r-- | applets/applet_tables.c | 55 |
1 files changed, 38 insertions, 17 deletions
diff --git a/applets/applet_tables.c b/applets/applet_tables.c index b5df74076..9f42ebf31 100644 --- a/applets/applet_tables.c +++ b/applets/applet_tables.c | |||
@@ -50,45 +50,66 @@ int main(int argc, char **argv) | |||
50 | 50 | ||
51 | qsort(applets, NUM_APPLETS, sizeof(applets[0]), cmp_name); | 51 | qsort(applets, NUM_APPLETS, sizeof(applets[0]), cmp_name); |
52 | 52 | ||
53 | /* Keep in sync with include/busybox.h! */ | ||
54 | |||
55 | puts("const char applet_names[] ALIGN1 ="); | ||
56 | ofs = 0; | 53 | ofs = 0; |
57 | i = 0; | ||
58 | for (i = 0; i < NUM_APPLETS; i++) { | 54 | for (i = 0; i < NUM_APPLETS; i++) { |
59 | offset[i] = ofs; | 55 | offset[i] = ofs; |
60 | ofs += strlen(applets[i].name) + 1; | 56 | ofs += strlen(applets[i].name) + 1; |
57 | } | ||
58 | /* We reuse 4 high-order bits of offset array for other purposes, | ||
59 | * so if they are indeed needed, refuse to proceed */ | ||
60 | if (ofs > 0xfff) | ||
61 | return 1; | ||
62 | if (!argv[1]) | ||
63 | return 1; | ||
64 | |||
65 | i = open(argv[1], O_WRONLY | O_TRUNC | O_CREAT, 0666); | ||
66 | if (i < 0) | ||
67 | return 1; | ||
68 | dup2(i, 1); | ||
69 | |||
70 | /* Keep in sync with include/busybox.h! */ | ||
71 | |||
72 | puts("/* This is a generated file, don't edit */"); | ||
73 | |||
74 | puts("const char applet_names[] ALIGN1 ="); | ||
75 | for (i = 0; i < NUM_APPLETS; i++) { | ||
61 | printf("\"%s\" \"\\0\"\n", applets[i].name); | 76 | printf("\"%s\" \"\\0\"\n", applets[i].name); |
62 | } | 77 | } |
63 | puts(";"); | 78 | puts(";"); |
64 | 79 | ||
65 | puts("int (*const applet_mains[])(int argc, char **argv) = {"); | 80 | puts("int (*const applet_main[])(int argc, char **argv) = {"); |
66 | for (i = 0; i < NUM_APPLETS; i++) { | 81 | for (i = 0; i < NUM_APPLETS; i++) { |
67 | printf("%s_main,\n", applets[i].main); | 82 | printf("%s_main,\n", applets[i].main); |
68 | } | 83 | } |
69 | puts("};"); | 84 | puts("};"); |
70 | 85 | ||
71 | #if ENABLE_FEATURE_INSTALLER || ENABLE_FEATURE_PREFER_APPLETS | ||
72 | puts("const uint32_t applet_nameofs[] = {"); | ||
73 | #else | ||
74 | puts("const uint16_t applet_nameofs[] ALIGN2 = {"); | 86 | puts("const uint16_t applet_nameofs[] ALIGN2 = {"); |
75 | #endif | ||
76 | for (i = 0; i < NUM_APPLETS; i++) { | 87 | for (i = 0; i < NUM_APPLETS; i++) { |
77 | printf("0x%08x,\n", | 88 | printf("0x%04x,\n", |
78 | offset[i] | 89 | offset[i] |
90 | #if ENABLE_FEATURE_PREFER_APPLETS | ||
91 | + (applets[i].nofork << 12) | ||
92 | + (applets[i].noexec << 13) | ||
93 | #endif | ||
79 | #if ENABLE_FEATURE_SUID | 94 | #if ENABLE_FEATURE_SUID |
80 | + (applets[i].need_suid << 14) /* 2 bits */ | 95 | + (applets[i].need_suid << 14) /* 2 bits */ |
81 | #endif | 96 | #endif |
82 | #if ENABLE_FEATURE_INSTALLER | ||
83 | + (applets[i].install_loc << 16) /* 3 bits */ | ||
84 | #endif | ||
85 | #if ENABLE_FEATURE_PREFER_APPLETS | ||
86 | + (applets[i].nofork << 19) | ||
87 | + (applets[i].noexec << 20) | ||
88 | #endif | ||
89 | ); | 97 | ); |
90 | } | 98 | } |
91 | puts("};"); | 99 | puts("};"); |
92 | 100 | ||
101 | #if ENABLE_FEATURE_INSTALLER | ||
102 | puts("const uint8_t applet_install_loc[] ALIGN1 = {"); | ||
103 | i = 0; | ||
104 | while (i < NUM_APPLETS) { | ||
105 | int v = applets[i].install_loc; /* 3 bits */ | ||
106 | if (++i < NUM_APPLETS) | ||
107 | v |= applets[i].install_loc << 4; /* 3 bits */ | ||
108 | printf("0x%02x,\n", v); | ||
109 | i++; | ||
110 | } | ||
111 | puts("};"); | ||
112 | #endif | ||
113 | |||
93 | return 0; | 114 | return 0; |
94 | } | 115 | } |