← Commit list

f6fb3c603

Denys Vlasenko
Denys Vlasenko
2025-08-10
SUCCESS Duration: 156s

Subject

ash: move 100 bytes off global .data / .bss, no logic changes

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

shell/ash.c+62 -61
@@ -386,6 +386,60 @@ static const char *const optletters_optnames[] ALIGN_PTR = {
enum { NOPTS = ARRAY_SIZE(optletters_optnames) };
+/* ============ Parser data */
+
+struct strlist {
+ struct strlist *next;
+ char *text;
+};
+
+struct alias;
+
+struct strpush {
+ struct strpush *prev; /* preceding string on stack */
+ char *prev_string;
+ int prev_left_in_line;
+#if ENABLE_ASH_ALIAS
+ struct alias *ap; /* if push was associated with an alias */
+#endif
+ char *string; /* remember the string since it may change */
+
+ /* Delay freeing so we can stop nested aliases. */
+ struct strpush *spfree;
+
+ /* Remember last two characters for pungetc. */
+ int lastc[2];
+
+ /* Number of outstanding calls to pungetc. */
+ int unget;
+};
+
+/*
+ * The parsefile structure pointed to by the global variable parsefile
+ * contains information about the current file being read.
+ */
+struct parsefile {
+ struct parsefile *prev; /* preceding file on stack */
+ int linno; /* current line */
+ int pf_fd; /* file descriptor (or -1 if string) */
+ int left_in_line; /* number of chars left in this line */
+ int left_in_buffer; /* number of chars left in this buffer past the line */
+ char *next_to_pgetc; /* next char in buffer */
+ char *buf; /* input buffer */
+ struct strpush *strpush; /* for pushing strings at this level */
+ struct strpush basestrpush; /* so pushing one is fast */
+
+ /* Delay freeing so we can stop nested aliases. */
+ struct strpush *spfree;
+
+ /* Remember last two characters for pungetc. */
+ int lastc[2];
+
+ /* Number of outstanding calls to pungetc. */
+ int unget;
+};
+
+
/* ============ Misc data */
#define msg_illnum "Illegal number: %s"
@@ -491,6 +545,10 @@ struct globals_misc {
char **trap_ptr; /* used only by "trap hack" */
+ char *commandname; /* currently executing command */
+ struct parsefile *g_parsefile; /* = &basepf, current input file */
+ struct parsefile basepf; /* top level input file */
+
/* Rarely referenced stuff */
struct jmploc main_handler;
@@ -531,6 +589,9 @@ extern struct globals_misc *BB_GLOBAL_CONST ash_ptr_to_globals_misc;
#define may_have_traps (G_misc.may_have_traps )
#define trap (G_misc.trap )
#define trap_ptr (G_misc.trap_ptr )
+#define commandname (G_misc.commandname)
+#define g_parsefile (G_misc.g_parsefile )
+#define basepf (G_misc.basepf )
#define main_handler (G_misc.main_handler )
#define groupinfo (G_misc.groupinfo )
#define random_gen (G_misc.random_gen )
@@ -541,6 +602,7 @@ extern struct globals_misc *BB_GLOBAL_CONST ash_ptr_to_globals_misc;
curdir = nullstr; \
physdir = nullstr; \
trap_ptr = trap; \
+ g_parsefile = &basepf; \
groupinfo.euid = -1; \
groupinfo.egid = -1; \
} while (0)
@@ -605,67 +667,6 @@ reset_exception_handler(void)
}
-/* ============ Parser data */
-
-/*
- * ash_vmsg() needs parsefile->fd, hence parsefile definition is moved up.
- */
-struct strlist {
- struct strlist *next;
- char *text;
-};
-
-struct alias;
-
-struct strpush {
- struct strpush *prev; /* preceding string on stack */
- char *prev_string;
- int prev_left_in_line;
-#if ENABLE_ASH_ALIAS
- struct alias *ap; /* if push was associated with an alias */
-#endif
- char *string; /* remember the string since it may change */
-
- /* Delay freeing so we can stop nested aliases. */
- struct strpush *spfree;
-
- /* Remember last two characters for pungetc. */
- int lastc[2];
-
- /* Number of outstanding calls to pungetc. */
- int unget;
-};
-
-/*
- * The parsefile structure pointed to by the global variable parsefile
- * contains information about the current file being read.
- */
-struct parsefile {
- struct parsefile *prev; /* preceding file on stack */
- int linno; /* current line */
- int pf_fd; /* file descriptor (or -1 if string) */
- int left_in_line; /* number of chars left in this line */
- int left_in_buffer; /* number of chars left in this buffer past the line */
- char *next_to_pgetc; /* next char in buffer */
- char *buf; /* input buffer */
- struct strpush *strpush; /* for pushing strings at this level */
- struct strpush basestrpush; /* so pushing one is fast */
-
- /* Delay freeing so we can stop nested aliases. */
- struct strpush *spfree;
-
- /* Remember last two characters for pungetc. */
- int lastc[2];
-
- /* Number of outstanding calls to pungetc. */
- int unget;
-};
-
-static struct parsefile basepf; /* top level input file */
-static struct parsefile *g_parsefile = &basepf; /* current input file */
-static char *commandname; /* currently executing command */
-
-
/* ============ Interrupts / exceptions */
static void exitshell(void) NORETURN;