diff options
author | Nick Shipp <git@segbrk.com> | 2020-05-16 11:13:42 -0400 |
---|---|---|
committer | Nick Shipp <git@segbrk.com> | 2020-05-16 11:13:42 -0400 |
commit | 39501543deccc7b8adaf4ffd66ffa3aaa8affc5a (patch) | |
tree | a97eb45d3e4aa255ab323c0275fd8eb151d1cdce | |
parent | 4300ce841cf0fe3379b538a1a32316f55b148aae (diff) |
-rw-r--r-- | Makefile | 17 | ||||
-rw-r--r-- | config.def.h | 16 | ||||
-rw-r--r-- | config.mk | 4 | ||||
-rw-r--r-- | sinit.c | 6 |
4 files changed, 26 insertions, 17 deletions
@@ -1,15 +1,24 @@ include config.mk -CC = diet -Os gcc +CC = diet -Os clang +LD = diet clang OBJ = sinit.o BIN = sinit -CFLAGS = -Os -flto -s -fno-asynchronous-unwind-tables -fno-unwind-tables -LDFLAGS = -flto -Os -static -Wl,--gc-sections -Wl,--strip-all -Wl,-z,norelro -fno-asynchronous-unwind-tables -Wl,--build-id=none +CFLAGS = -Oz -flto -fno-asynchronous-unwind-tables -fno-unwind-tables -ffunction-sections -fdata-sections +LDFLAGS = -flto -O2 -static -Wl,--gc-sections -Wl,--strip-all -Wl,-z,norelro -fno-asynchronous-unwind-tables -Wl,--build-id=none all: $(BIN) poweroff reboot +reboot: reboot.o + $(LD) $(LDFLAGS) -o $@ $(OBJ) $(LDLIBS) + strip -R .comment -R .jcr -R .eh_data -R .note -R .eh_frame $@ + +poweroff: poweroff.o + $(LD) $(LDFLAGS) -o $@ $(OBJ) $(LDLIBS) + strip -R .comment -R .jcr -R .eh_data -R .note -R .eh_frame $@ + $(BIN): $(OBJ) - $(CC) $(LDFLAGS) -o $@ $(OBJ) $(LDLIBS) + $(LD) $(LDFLAGS) -o $@ $(OBJ) $(LDLIBS) strip -R .comment -R .jcr -R .eh_data -R .note -R .eh_frame $@ $(OBJ): config.h diff --git a/config.def.h b/config.def.h index 9fcbc98..39cae29 100644 --- a/config.def.h +++ b/config.def.h @@ -5,20 +5,20 @@ #define USERNAME "who" #define HOMEDIR "/home/" USERNAME -uid_t uid = 1000; -gid_t gid = 1000; +static uid_t uid = 1000; +static gid_t gid = 1000; /* Enable startup profiling with perf(1) */ // #define PERF #ifdef PERF -static char *const perf[] = { +static const char *const perf[] = { "/usr/bin/perf", "record", "-ag", "--output=/tmp/perf.data", "--", "sleep", "3" }; #endif /* constant groups to set for user session */ -static gid_t const groups[] = { +static const gid_t groups[] = { 5, /* tty */ 10, /* wheel */ 91, /* video */ @@ -27,7 +27,7 @@ static gid_t const groups[] = { int udev_settled(void); -static struct { +static const struct { int (*dep)(); char *argv[6]; } init_procs[] = { @@ -41,7 +41,7 @@ static struct { udev_settled, { "/usr/bin/illum-d", NULL }, }; -static struct { +static const struct { char *source; char *target; char *type; @@ -56,7 +56,7 @@ static struct { { "tmpfs", "/run", "tmpfs", MS_NOSUID|MS_NODEV, "mode=755" }, }; -static char *const user_env[] = { +static const char *const user_env[] = { "HOME=" HOMEDIR, "PWD=" HOMEDIR, "PATH=/usr/bin", @@ -68,7 +68,7 @@ static char *const user_env[] = { NULL }; -static char *const user_procs[][5] = { +static const char *const user_procs[][5] = { { "/usr/bin/xinit", "/usr/bin/dwm", "--", "-quiet", NULL }, }; @@ -5,8 +5,8 @@ VERSION = 1.0 PREFIX = /usr/local MANPREFIX = $(PREFIX)/share/man -CC = cc +CC = clang LD = $(CC) CPPFLAGS = -CFLAGS = -Wextra -Wall -Os +CFLAGS = -Wextra -Wall -Oz LDFLAGS = -s -static @@ -22,7 +22,7 @@ static void sigpoweroff(void); static void sigreap(void); static void sigreboot(void); static void spawn(int (*)(), char *const []); -static void spawn_as(uid_t, gid_t, char *const [], char *const []); +static void spawn_as(uid_t, gid_t, const char *const [], const char *const []); static void mounts(void); static void ifup(const char *iface); @@ -156,7 +156,7 @@ spawn(int (*dep)(), char *const argv[]) } static void -spawn_as(uid_t uid, gid_t gid, char *const env[], char *const argv[]) +spawn_as(uid_t uid, gid_t gid, const char *const env[], const char *const argv[]) { /* printf("spawn_as %d,%d: %s\n", uid, gid, argv[0]); */ switch (fork()) { @@ -168,7 +168,7 @@ spawn_as(uid_t uid, gid_t gid, char *const env[], char *const argv[]) setgid(gid); setgroups(LEN(groups), groups); setuid(uid); - execve(argv[0], argv, env); + execve(argv[0], (char *const *)argv, (char *const *)env); #ifdef SANE write(2, "can't exec\n", 11); _exit(1); |