diff --git a/Makefile b/Makefile index 35545eb06..f8eec8447 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,9 @@ COREUTILS_SRC = \ LIBBB_A_SRC = \ libbb/lineedit.c \ - libbb/lineedptrhack.c \ + libbb/lineedptrhack.c + +LIBBB_B_SRC = \ libbb/appletlib.c \ libbb/getopt32.c \ libbb/error.retval.c \ @@ -36,7 +38,7 @@ LIBBB_A_SRC = \ libbb/bb.basename.c \ libbb/mempcpy.c -LIBBB_B_SRC = \ +LIBBB_C_SRC = \ libbb/perror.msg.c \ libbb/signal.names.c \ libbb/ptrtoglobals.c \ @@ -50,7 +52,9 @@ LIBBB_B_SRC = \ libbb/s.gethostname.c \ libbb/safe.poll.c \ libbb/parse.mode.c \ - libbb/poll.c \ + libbb/poll.c + +LIBBB_D_SRC = \ libbb/xfuncs.printf.c \ libbb/xfuncs.c \ libbb/xgetcwd.c \ @@ -64,10 +68,24 @@ LIBBB_B_SRC = \ libbb/unicode.c \ libbb/vfork.and.run.c -SRCS = $(MAIN_SRC) $(SHELL_OTHER_SRC) $(COREUTILS_SRC) $(LIBBB_A_SRC) $(LIBBB_B_SRC) +SRCS = $(MAIN_SRC) $(SHELL_OTHER_SRC) $(COREUTILS_SRC) $(LIBBB_A_SRC) \ + $(LIBBB_B_SRC) $(LIBBB_C_SRC) $(LIBBB_D_SRC) OBJS = $(SRCS:.c=.a) ROOT = $(MAIN_SRC:.c=.root) +SHELL_OTHER_SEG = -SSHELLOTHER +COREUTILS_SEG = -SCOREUTILS_ +LIBBB_A_SEG = -SLIBBB_A___ +LIBBB_C_SEG = -SLIBBB_C___ +# We need more separate segments in debug mode because the code is bigger. +.IF $(DEBUG) +LIBBB_B_SEG = -SLIBBB_B___ +LIBBB_D_SEG = -SLIBBB_D___ +.ELSE +LIBBB_B_SEG = -SLIBBB_A___ +LIBBB_D_SEG = -SLIBBB_C___ +.END + INCLUDES = -I include -I shell -I libbb DEFINES = -Dhush_main=main -DNDEBUG @@ -79,11 +97,12 @@ DEFINES += -DF_SETFD=-1 -DFD_CLOEXEC=-1 # optimize bit 3 set (no stack repair code). # Optimize bit 6 breaks some standard-compliant varargs code, # and bits 0, 4, and 5 have known bugs. Disable for now. -OCC_FLAGS = -i -w -a0 -O8 +CFLAGS = -i -w -a0 -O8 STACKSIZE = 20480 -# Add $(OCC_FLAGS) to CFLAGS on dmake -CFLAGS = $(null, $(OCC_FLAGS)) +.IF $(DEBUG) +CFLAGS += -g -DDEBUG +.END PROG = hush @@ -93,10 +112,12 @@ $(PROG): $(OBJS) %.a: %.c $(CC) $(INCLUDES) $(DEFINES) $(CFLAGS) -c $< -o $@ \ $(eq,$<,$(MAIN_SRC) -s$(STACKSIZE) -r) \ - $(!eq,$(SHELL_OTHER_SRC:s/$> 14) & 0x3) #endif -#if ENABLE_FEATURE_INSTALLER -#define APPLET_INSTALL_LOC(i) ({ \ - unsigned v = (i); \ - if (v & 1) v = applet_install_loc[v/2] >> 4; \ - else v = applet_install_loc[v/2] & 0xf; \ - v; }) -#endif - /* Length of these names has effect on size of libbusybox * and "individual" binaries. Keep them short. diff --git a/include/libbb.h b/include/libbb.h index 985119348..2bb59ba56 100644 --- a/include/libbb.h +++ b/include/libbb.h @@ -16,7 +16,6 @@ #include #include #include -#include #include #include #if defined __UCLIBC__ /* TODO: and glibc? */ @@ -948,12 +947,10 @@ enum { DAEMON_DOUBLE_FORK = 16 /* double fork to avoid controlling tty */ }; #if BB_MMU - enum { re_execed = 0 }; # define fork_or_rexec(argv) xfork() # define bb_daemonize_or_rexec(flags, argv) bb_daemonize_or_rexec(flags) # define bb_daemonize(flags) bb_daemonize_or_rexec(flags, bogus) #else - extern bool re_execed; /* Note: re_exec() and fork_or_rexec() do argv[0][0] |= 0x80 on NOMMU! * _Parent_ needs to undo it if it doesn't want to have argv[0] mangled. */ @@ -1008,25 +1005,11 @@ llist_t *llist_find_str(llist_t *first, const char *str) FAST_FUNC; * llist_t *llist_add_to(llist_t *old_head, void *data) * etc does not result in smaller code... */ -/* start_stop_daemon and udhcpc are special - they want - * to create pidfiles regardless of FEATURE_PIDFILE */ -#if ENABLE_FEATURE_PIDFILE || defined(WANT_PIDFILE) -/* True only if we created pidfile which is *file*, not /dev/null etc */ -extern smallint wrote_pidfile; -void write_pidfile(const char *path) FAST_FUNC; -#define remove_pidfile(path) do { if (wrote_pidfile) unlink(path); } while (0) -#else -enum { wrote_pidfile = 0 }; -#define write_pidfile(path) ((void)0) -#define remove_pidfile(path) ((void)0) -#endif - enum { LOGMODE_NONE = 0, LOGMODE_STDIO = (1 << 0) }; extern const char *msg_eol; -extern smallint syslog_level; extern smallint logmode; extern int die_sleep; extern uint8_t xfunc_error_retval; @@ -1103,7 +1086,6 @@ struct hwtype { int FAST_FUNC (*activate)(int fd); int suppress_null_addr; }; -extern smallint interface_opt_a; int display_interfaces(char *ifname) FAST_FUNC; int in_ether(const char *bufp, struct sockaddr *sap) FAST_FUNC; #if ENABLE_FEATURE_HWIB @@ -1488,7 +1470,6 @@ unsigned get_cpu_count(void) FAST_FUNC; char *percent_decode_in_place(char *str, int strict) FAST_FUNC; -extern uint32_t *global_crc32_table; uint32_t *crc32_filltable(uint32_t *tbl256, int endian) FAST_FUNC; uint32_t crc32_block_endian1(uint32_t val, const void *buf, unsigned len, uint32_t *crc_table) FAST_FUNC; uint32_t crc32_block_endian0(uint32_t val, const void *buf, unsigned len, uint32_t *crc_table) FAST_FUNC; @@ -1521,8 +1502,6 @@ void bb_progress_update(bb_progress_t *p, uoff_t totalsize) FAST_FUNC; -extern const char *applet_name; - /* Some older linkers don't perform string merging, we used to have common strings * as global arrays to do it by hand. But: * (1) newer linkers do it themselves, diff --git a/libbb/verror.msg.c b/libbb/verror.msg.c index 0ef2a311f..135918442 100644 --- a/libbb/verror.msg.c +++ b/libbb/verror.msg.c @@ -17,6 +17,8 @@ smallint syslog_level = LOG_ERR; smallint logmode = LOGMODE_STDIO; const char *msg_eol = "\n"; +extern const char *applet_name; + void FAST_FUNC bb_verror_msg(const char *s, va_list p, const char* strerr) { char *msg, *msg1; diff --git a/shell/glob.c b/shell/glob.c index 90bab4d3d..6e4b9a8ab 100644 --- a/shell/glob.c +++ b/shell/glob.c @@ -11,8 +11,6 @@ * unsupported: GLOB_BRACE GLOB_ALTDIRFUNC GLOB_MAGCHAR */ -#define DEBUG(x) - #include "glob.h" #include diff --git a/shell/hush.c b/shell/hush.c index 414c8a547..2f4e28734 100644 --- a/shell/hush.c +++ b/shell/hush.c @@ -3417,6 +3417,10 @@ static int done_word(o_string *word, struct parse_context *ctx) } +#if defined(__ORCAC__) && defined(DEBUG) +segment "HUSH_B____"; +#endif + /* Peek ahead in the input to find out if we have a "&n" construct, * as in "2>&1", that represents duplicating a file descriptor. * Return: @@ -5638,7 +5642,7 @@ static char **expand_assignments(char **argv, int count) #ifdef __ORCAC__ -segment "HUSH_B____"; +segment "HUSH_C____"; #endif static void switch_off_special_sigs(unsigned mask) @@ -7502,6 +7506,10 @@ static void forked_child(void *args_struct) { #endif +#if defined(__ORCAC__) && defined(DEBUG) +segment "HUSH_D____"; +#endif + /* NB: called by pseudo_exec, and therefore must not modify any * global data until exec/_exit (we can be a child after vfork!) */ static int run_list(struct pipe *pi) diff --git a/texttogs b/texttogs new file mode 100644 index 000000000..9c78f306b --- /dev/null +++ b/texttogs @@ -0,0 +1 @@ +udl -g include/*.h coreutils/*.c libbb/*.c shell/*.c shell/*.h Makefile \ No newline at end of file