Browse Source

Strip all object files of all non global symbols and .note and
.comment, saving a lot of space in the resultant binaries...
-Erik

Eric Andersen 23 years ago
parent
commit
430e386b9e

+ 1 - 1
Makefile

@@ -28,7 +28,7 @@
 
 
 
-DIRS = misc pwd_grp stdio string termios unistd net signal stdlib sysdeps
+DIRS = io misc pwd_grp stdio string termios unistd net signal stdlib sysdeps
 
 all: libc.a
 

+ 2 - 0
include/fcntl.h

@@ -57,11 +57,13 @@ __BEGIN_DECLS
 
 /* Do the file control operation described by CMD on FD.
    The remaining arguments are interpreted depending on CMD.  */
+extern int __fcntl __P ((int __fd, int __cmd, ...));
 extern int fcntl __P ((int __fd, int __cmd, ...));
 
 /* Open FILE and return a new file descriptor for it, or -1 on error.
    OFLAG determines the type of access used.  If O_CREAT is on OFLAG,
    the third argument is taken as a `mode_t', the mode of the created file.  */
+extern int __open __P ((__const char *__file, int __oflag, mode_t mode));
 #ifndef __USE_FILE_OFFSET64
 extern int open __P ((__const char *__file, int __oflag, ...));
 #else

+ 2 - 0
libc/inet/Makefile

@@ -47,9 +47,11 @@ ar-target: $(OBJS)
 
 $(MOBJ): $(MSRC)
 	$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 $(MOBJ2): $(MSRC2)
 	$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 $(OBJS): Makefile
 

+ 4 - 0
libc/inet/rpc/Makefile

@@ -39,6 +39,10 @@ COBJS=$(patsubst %.c,%.o, $(CSRC))
 
 all: $(COBJS) $(LIBC)
 
+$(COBJS):
+	$(CC) $(CFLAGS) $< -c $*.c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
+
 $(LIBC): $(COBJS)
 	$(AR) $(ARFLAGS) $(LIBC) $(COBJS)
 

+ 3 - 1
libc/misc/assert/Makefile

@@ -35,7 +35,9 @@ $(LIBC): ar-target
 ar-target: $(OBJS)
 	$(AR) $(ARFLAGS) $(LIBC) $(OBJS)
 
-$(OBJS): Makefile
+$(COBJS):
+	$(CC) $(CFLAGS) $< -c $*.c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 clean:
 	rm -f *.[oa] *~ core

+ 1 - 0
libc/misc/ctype/Makefile

@@ -38,6 +38,7 @@ ar-target: $(OBJS)
 
 $(MOBJ): $(MSRC)
 	$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 $(OBJS): Makefile
 

+ 3 - 1
libc/misc/fnmatch/Makefile

@@ -35,7 +35,9 @@ $(LIBC): ar-target
 ar-target: $(OBJS)
 	$(AR) $(ARFLAGS) $(LIBC) $(OBJS)
 
-$(OBJS): Makefile
+$(COBJS):
+	$(CC) $(CFLAGS) $< -c $*.c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 clean:
 	rm -f *.[oa] *~ core

+ 3 - 1
libc/misc/glob/Makefile

@@ -35,7 +35,9 @@ $(LIBC): ar-target
 ar-target: $(OBJS)
 	$(AR) $(ARFLAGS) $(LIBC) $(OBJS)
 
-$(OBJS): Makefile
+$(COBJS):
+	$(CC) $(CFLAGS) $< -c $*.c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 clean:
 	rm -f *.[oa] *~ core

+ 3 - 1
libc/misc/internals/Makefile

@@ -35,7 +35,9 @@ $(LIBC): ar-target
 ar-target: $(OBJS)
 	$(AR) $(ARFLAGS) $(LIBC) $(OBJS)
 
-$(OBJS): Makefile
+$(COBJS):
+	$(CC) $(CFLAGS) $< -c $*.c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 clean:
 	rm -f *.[oa] *~ core

+ 3 - 1
libc/misc/lsearch/Makefile

@@ -35,7 +35,9 @@ $(LIBC): ar-target
 ar-target: $(OBJS)
 	$(AR) $(ARFLAGS) $(LIBC) $(OBJS)
 
-$(OBJS): Makefile
+$(COBJS):
+	$(CC) $(CFLAGS) $< -c $*.c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 clean:
 	rm -f *.[oa] *~ core

+ 3 - 1
libc/misc/regex/Makefile

@@ -35,7 +35,9 @@ $(LIBC): ar-target
 ar-target: $(OBJS)
 	$(AR) $(ARFLAGS) $(LIBC) $(OBJS)
 
-$(OBJS): Makefile
+$(COBJS):
+	$(CC) $(CFLAGS) $< -c $*.c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 clean:
 	rm -f *.[oa] *~ core

+ 3 - 1
libc/misc/time/Makefile

@@ -36,7 +36,9 @@ $(LIBC): ar-target
 ar-target: $(OBJS)
 	$(AR) $(ARFLAGS) $(LIBC) $(OBJS)
 
-$(OBJS): Makefile
+$(COBJS):
+	$(CC) $(CFLAGS) $< -c $*.c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 clean:
 	rm -f *.[oa] *~ core

+ 6 - 1
libc/pwd_grp/Makefile

@@ -37,7 +37,12 @@ $(LIBC): ar-target
 ar-target: $(OBJS)
 	$(AR) $(ARFLAGS) $(LIBC) $(OBJS)
 
-$(OBJS): Makefile
+$(COBJS):
+	$(CC) $(CFLAGS) $< -c $*.c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
+
+$(OBJ): Makefile
+
 __getgrent.c: config.h
 initgroups.c: config.h
 

+ 4 - 2
libc/signal/Makefile

@@ -24,7 +24,7 @@ TOPDIR=../
 include $(TOPDIR)Rules.mak
 LIBC=$(TOPDIR)libc.a
 
-CSRC=raise.c sys_siglist.c
+CSRC=raise.c
 COBJS=$(patsubst %.c,%.o, $(CSRC))
 OBJS=$(COBJS)
 
@@ -35,7 +35,9 @@ $(LIBC): ar-target
 ar-target: $(OBJS)
 	$(AR) $(ARFLAGS) $(LIBC) $(OBJS)
 
-$(OBJS): Makefile
+$(COBJS):
+	$(CC) $(CFLAGS) $< -c $*.c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 clean:
 	rm -f *.[oa] *~ core

+ 8 - 1
libc/stdio/Makefile

@@ -50,14 +50,21 @@ ar-target: $(OBJS)
 
 $(MOBJ): $(MSRC)
 	$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 $(MOBJ2): $(MSRC2)
 	$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 $(MOBJ3): $(MSRC3)
 	$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
-$(OBJS): Makefile
+$(COBJS):
+	$(CC) $(CFLAGS) $< -c $*.c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
+
+$(OBJ): Makefile
 
 clean:
 	rm -f *.[oa] *~ core

+ 6 - 0
libc/stdlib/Makefile

@@ -46,9 +46,15 @@ ar-target: $(OBJS)
 
 $(MOBJ): $(MSRC)
 	$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 $(MOBJ2): $(MSRC2)
 	$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
+
+$(COBJS):
+	$(CC) $(CFLAGS) $< -c $*.c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 $(OBJ): Makefile
 

+ 4 - 1
libc/stdlib/malloc-simple/Makefile

@@ -38,8 +38,11 @@ ar-target: $(OBJS)
 
 $(MOBJ): $(MSRC)
 	$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
-$(OBJ): Makefile
+$(COBJS):
+	$(CC) $(CFLAGS) $< -c $*.c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 clean:
 	rm -f *.[oa] *~ core

+ 4 - 1
libc/stdlib/malloc/Makefile

@@ -40,8 +40,11 @@ ar-target: $(OBJS)
 
 $(MOBJ): $(MSRC)
 	$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
-$(OBJ): Makefile
+$(COBJS):
+	$(CC) $(CFLAGS) $< -c $*.c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 clean:
 	rm -f *.[oa] *~ core

+ 5 - 1
libc/string/Makefile

@@ -47,11 +47,15 @@ ar-target: $(OBJS)
 
 $(MOBJ): $(MSRC)
 	$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 $(MOBJ1): $(MSRC1)
 	$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
-$(OBJS): Makefile
+$(COBJS):
+	$(CC) $(CFLAGS) $< -c $*.c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 clean:
 	rm -f *.[oa] *~ core

+ 34 - 2
libc/string/strsignal.c

@@ -8,8 +8,40 @@
 #include <malloc.h>
 #include <signal.h>
 
-extern __const char *__const _sys_siglist[_NSIG];
-extern __const char *__const sys_siglist[_NSIG];
+const char *const sys_siglist[NSIG] = {
+	"Unknown signal",
+	"Hangup",
+	"Interrupt",
+	"Quit",
+	"Illegal instruction",
+	"Trace/breakpoint trap",
+	"IOT trap/Abort",
+	"Bus error",
+	"Floating point exception",
+	"Killed",
+	"User defined signal 1",
+	"Segmentation fault",
+	"User defined signal 2",
+	"Broken pipe",
+	"Alarm clock",
+	"Terminated",
+	"Stack fault",
+	"Child exited",
+	"Continued",
+	"Stopped (signal)",
+	"Stopped",
+	"Stopped (tty input)",
+	"Stopped (tty output)",
+	"Possible I/O",
+	"CPU time limit exceeded",
+	"File size limit exceeded",
+	"Virtual time alarm",
+	"Profile signal",
+	"Window size changed",
+	"File lock lost",
+	"Power failure",
+	"Unused signal"
+};
 
 /********************** Function strsignal ************************************/
 

+ 3 - 1
libc/sysdeps/linux/common/Makefile

@@ -37,7 +37,9 @@ $(LIBC): ar-target
 ar-target: $(OBJ)
 	$(AR) $(ARFLAGS) $(LIBC) $(OBJ)
 
-$(OBJ): Makefile
+$(COBJS):
+	$(CC) $(CFLAGS) $< -c $*.c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 clean:
 	rm -f *.[oa] *~ core

+ 14 - 3
libc/sysdeps/linux/i386/Makefile

@@ -31,9 +31,13 @@ ASMOBJS=$(shell ./list_syscalls.sh)
 SSRC=_start.S setjmp.S longjmp.S #fork.S #clone.S
 SOBJS=$(patsubst %.S,%.o, $(SSRC))
 
+MSRC=syscalls.c
+MOBJ=read.o write.o __open.o close.o
+
 CSRC=readdir.c #select.c
 COBJS=$(patsubst %.c,%.o, $(CSRC))
-OBJS=$(SOBJS) $(ASMOBJS) $(COBJS)
+
+OBJS=$(SOBJS) $(ASMOBJS) $(COBJS) $(MOBJ)
 
 
 all: $(OBJS) $(LIBC)
@@ -45,12 +49,19 @@ ar-target: $(OBJS)
 
 $(ASMOBJS): $(ASMSRC)
 	$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 $(SOBJS): $(SSRC)
+	$(CC) $(CFLAGS) $< -c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
-$(COBJS): $(CSRC)
+$(MOBJ): $(MSRC)
+	$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
-$(OBJS): Makefile
+$(COBJS):
+	$(CC) $(CFLAGS) $< -c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 clean:
 	rm -f *.[oa] *~ core

+ 4 - 1
libc/termios/Makefile

@@ -43,8 +43,11 @@ ar-target: $(OBJS)
 
 $(MOBJ): $(MSRC)
 	$(CC) $(CFLAGS) -DL_$* $< -c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
-$(OBJS): Makefile
+$(COBJS):
+	$(CC) $(CFLAGS) $< -c $*.c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
 
 clean:
 	rm -f *.[oa] *~ core

+ 4 - 0
libc/unistd/Makefile

@@ -37,6 +37,10 @@ $(LIBC): ar-target subdirs
 ar-target: $(OBJS)
 	$(AR) $(ARFLAGS) $(LIBC) $(OBJS)
 
+$(COBJS):
+	$(CC) $(CFLAGS) $< -c $*.c -o $*.o
+	$(STRIPTOOL) -x -R .note -R .comment $*.o
+
 $(OBJ): Makefile
 
 subdirs: $(patsubst %, _dir_%, $(DIRS))