From 755ec12eac1030fc9dbffc9594386e07d0153b04 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Thu, 17 Jan 2013 10:54:40 -0800 Subject: [PATCH] Always strip all the modules Always strip the modules; they are too big unstripped. Specifically, we generate unstripped *.elf files, and then convert them to stripped *.c32 files. Signed-off-by: H. Peter Anvin --- com32/chain/Makefile | 2 +- com32/cmenu/Makefile | 9 +++++---- com32/elflink/ldlinux/Makefile | 6 +++--- com32/gfxboot/Makefile | 2 +- com32/gpllib/Makefile | 4 ++-- com32/hdt/Makefile | 2 +- com32/lib/Makefile | 4 ++-- com32/libutil/Makefile | 5 +++-- com32/lua/src/Makefile | 7 ++++--- com32/mboot/Makefile | 2 +- com32/menu/Makefile | 4 ++-- com32/modules/Makefile | 2 +- com32/sysdump/Makefile | 2 +- mk/elf.mk | 6 +++++- mk/lib.mk | 3 +++ 15 files changed, 35 insertions(+), 25 deletions(-) diff --git a/com32/chain/Makefile b/com32/chain/Makefile index 9a298fa..ed37ffa 100644 --- a/com32/chain/Makefile +++ b/com32/chain/Makefile @@ -20,7 +20,7 @@ OBJS = chain.o partiter.o utility.o options.o mangle.o all: chain.c32 -chain.c32: $(OBJS) $(C_LIBS) +chain.elf: $(OBJS) $(C_LIBS) $(LD) $(LDFLAGS) -o $@ $^ %.o: %.c diff --git a/com32/cmenu/Makefile b/com32/cmenu/Makefile index 181937b..f827afd 100644 --- a/com32/cmenu/Makefile +++ b/com32/cmenu/Makefile @@ -44,14 +44,15 @@ MENUS = $(LIBS) $(CMENUS) $(IMENUS) all: menus -libmenu/libmenu.c32: $(LIBMENU) - $(LD) -shared $(LDFLAGS) -o $@ $^ +libmenu/libmenu.elf: $(LIBMENU) + $(LD) -shared $(LDFLAGS) -soname $(patsubst %.elf,%.c32,$(@F)) \ + -o $@ $^ tidy dist: - rm -f *.o *.lo *.c32 *.lst *.elf .*.d */.*.d + rm -f *.o *.lo *.lst *.elf */*.o */*.elf .*.d */.*.d libclean: - rm -f libmenu/*.o libmenu/*.c32 + rm -f libmenu/*.c32 clean: tidy menuclean libclean rm -f *.lss *.c32 *.com diff --git a/com32/elflink/ldlinux/Makefile b/com32/elflink/ldlinux/Makefile index fa53226..b2d0cec 100644 --- a/com32/elflink/ldlinux/Makefile +++ b/com32/elflink/ldlinux/Makefile @@ -1,6 +1,6 @@ ## ----------------------------------------------------------------------- ## -## Copyright 2011 Intel Corporation - All Rights Reserved +## Copyright 2011-2013 Intel Corporation - All Rights Reserved ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -21,10 +21,10 @@ BTARGET = ldlinux.c32 all: $(BTARGET) ldlinux_lnx.a -ldlinux.c32 : ldlinux.o cli.o readconfig.o refstr.o colors.o getadv.o \ +ldlinux.elf : ldlinux.o cli.o readconfig.o refstr.o colors.o getadv.o \ adv.o execute.o chainboot.o kernel.o get_key.o \ advwrite.o setadv.o eprintf.o loadhigh.o msg.o - $(LD) $(LDFLAGS) -soname $(@F) -o $@ $^ $(LIBS) + $(LD) $(LDFLAGS) -soname $(patsubst %.elf,%.c32,$(@F)) -o $@ $^ $(LIBS) LNXCFLAGS += -D__export='__attribute__((visibility("default")))' LNXLIBOBJS = get_key.lo diff --git a/com32/gfxboot/Makefile b/com32/gfxboot/Makefile index f2a7376..bd0bab1 100644 --- a/com32/gfxboot/Makefile +++ b/com32/gfxboot/Makefile @@ -19,7 +19,7 @@ MODULES = gfxboot.c32 all: $(MODULES) -gfxboot.c32 : gfxboot.o realmode_callback.o $(LIBS) $(C_LIBS) +gfxboot.elf : gfxboot.o realmode_callback.o $(LIBS) $(C_LIBS) $(LD) $(LDFLAGS) -o $@ $^ realmode_callback.o: realmode_callback.asm diff --git a/com32/gpllib/Makefile b/com32/gpllib/Makefile index 053e864..c704866 100644 --- a/com32/gpllib/Makefile +++ b/com32/gpllib/Makefile @@ -21,8 +21,8 @@ COM32DIR = $(AUXDIR)/com32 all: libcom32gpl.c32 -libcom32gpl.c32 : $(LIBOBJS) - $(LD) -shared $(LDFLAGS) -soname $(@F) -o $@ $^ +libcom32gpl.elf : $(LIBOBJS) + $(LD) -shared $(LDFLAGS) -soname $(patsubst %.elf,%.c32,$(@F)) -o $@ $^ tidy dist clean: find . \( -name \*.o -o -name .\*.d -o -name \*.tmp \) -print0 | \ diff --git a/com32/hdt/Makefile b/com32/hdt/Makefile index d264b5b..42f5c0d 100644 --- a/com32/hdt/Makefile +++ b/com32/hdt/Makefile @@ -52,7 +52,7 @@ QEMU ?= qemu-kvm all: $(MODULES) $(TESTFILES) -hdt.c32 : $(OBJS) $(LIBS) $(C_LIBS) +hdt.elf : $(OBJS) $(LIBS) $(C_LIBS) $(LD) $(LDFLAGS) -o $@ $^ memtest: diff --git a/com32/lib/Makefile b/com32/lib/Makefile index 7806230..dd1ef7c 100644 --- a/com32/lib/Makefile +++ b/com32/lib/Makefile @@ -214,9 +214,9 @@ COM32DIR = $(AUXDIR)/com32 all: libcom32.c32 libcom32min.a libcom32core.a -libcom32.c32 : $(LIBOBJS) +libcom32.elf : $(LIBOBJS) rm -f $@ - $(LD) -shared $(LDFLAGS) -soname $(@F) -o $@ $^ + $(LD) -shared $(LDFLAGS) -soname $(patsubst %.elf,%.c32,$(@F)) -o $@ $^ libcom32min.a : $(MINLIBOBJS) rm -f $@ diff --git a/com32/libutil/Makefile b/com32/libutil/Makefile index fb437dc..42f69dc 100644 --- a/com32/libutil/Makefile +++ b/com32/libutil/Makefile @@ -41,8 +41,9 @@ LNXLIBOBJS = $(patsubst %.o,%.lo,$(LIBOBJS)) all: libutil_com.c32 libutil_lnx.a -libutil_com.c32: $(LIBOBJS) - $(LD) $(LDFLAGS) -soname $(@F) -o $@ $^ +.PRECIOUS: libutil_com.elf +libutil_com.elf: $(LIBOBJS) + $(LD) $(LDFLAGS) -soname $(patsubst %.elf,%.c32,$(@F)) -o $@ $^ libutil_lnx.a: $(LNXLIBOBJS) rm -f $@ diff --git a/com32/lua/src/Makefile b/com32/lua/src/Makefile index 01d1f81..d70d23e 100644 --- a/com32/lua/src/Makefile +++ b/com32/lua/src/Makefile @@ -50,10 +50,11 @@ CFLAGS += -DLUA_ANSI all: $(MODULES) $(TESTFILES) -$(LIBLUA) : $(LIBLUA_OBJS) - $(LD) -shared $(LDFLAGS) -o $@ $^ +liblua.elf : $(LIBLUA_OBJS) + $(LD) $(LDFLAGS) -shared -soname $(patsubst %.elf,%.c32,$(@F)) \ + -o $@ $^ -lua.c32 : $(OBJS) $(LIBLUA) $(C_LIBS) +lua.elf : $(OBJS) $(LIBLUA) $(C_LIBS) $(LD) $(LDFLAGS) -o $@ $^ tidy dist: diff --git a/com32/mboot/Makefile b/com32/mboot/Makefile index 02e9f49..6e010b1 100644 --- a/com32/mboot/Makefile +++ b/com32/mboot/Makefile @@ -28,7 +28,7 @@ OBJS = mboot.o map.o mem.o initvesa.o apm.o solaris.o syslinux.o all: $(MODULES) $(TESTFILES) -mboot.c32 : $(OBJS) $(C_LIBS) +mboot.elf : $(OBJS) $(C_LIBS) $(LD) $(LDFLAGS) -o $@ $^ tidy dist: diff --git a/com32/menu/Makefile b/com32/menu/Makefile index b771945..e62c6b8 100644 --- a/com32/menu/Makefile +++ b/com32/menu/Makefile @@ -28,10 +28,10 @@ COMMONOBJS = menumain.o readconfig.o passwd.o drain.o printmsg.o colors.o \ all: $(MODULES) $(TESTFILES) -menu.c32 : menu.o $(COMMONOBJS) $(C_LIBS) +menu.elf : menu.o $(COMMONOBJS) $(C_LIBS) $(LD) $(LDFLAGS) -o $@ $^ -vesamenu.c32 : vesamenu.o $(COMMONOBJS) $(C_LIBS) +vesamenu.elf : vesamenu.o $(COMMONOBJS) $(C_LIBS) $(LD) $(LDFLAGS) -o $@ $^ tidy dist: diff --git a/com32/modules/Makefile b/com32/modules/Makefile index 9cf4da8..628fa5d 100644 --- a/com32/modules/Makefile +++ b/com32/modules/Makefile @@ -35,7 +35,7 @@ all: $(MODULES) $(TESTFILES) dmitest.o: dmitest.c $(CC) $(CFLAGS) $(GPLINCLUDE) -c -o $@ $< -dmitest.c32 : dmi_utils.o dmitest.o $(C_LIBS) +dmitest.elf : dmi_utils.o dmitest.o $(C_LIBS) $(LD) $(LDFLAGS) -o $@ $^ tidy dist: diff --git a/com32/sysdump/Makefile b/com32/sysdump/Makefile index 8763b3c..7d42ae0 100644 --- a/com32/sysdump/Makefile +++ b/com32/sysdump/Makefile @@ -45,7 +45,7 @@ CFLAGS += -DDATE='"$(DATE)"' all: $(MODULES) $(TESTFILES) -sysdump.c32 : $(OBJS) $(LIBS) $(C_LIBS) +sysdump.elf : $(OBJS) $(LIBS) $(C_LIBS) $(LD) $(LDFLAGS) -o $@ $^ tidy dist: diff --git a/mk/elf.mk b/mk/elf.mk index 160dadc..f759b70 100644 --- a/mk/elf.mk +++ b/mk/elf.mk @@ -81,5 +81,9 @@ C_LNXLIBS = $(com32)/libutil/libutil_lnx.a \ %.lnx: %.lo $(LNXLIBS) $(C_LNXLIBS) $(CC) $(LNXCFLAGS) -o $@ $^ -%.c32: %.o $(C_LIBS) +.PRECIOUS: %.elf +%.elf: %.o $(C_LIBS) $(LD) $(LDFLAGS) -o $@ $^ + +%.c32: %.elf + $(OBJCOPY) --strip-debug --strip-unneeded $< $@ diff --git a/mk/lib.mk b/mk/lib.mk index ea817e6..ca8e41b 100644 --- a/mk/lib.mk +++ b/mk/lib.mk @@ -79,3 +79,6 @@ LDFLAGS = -m elf_i386 --hash-style=gnu -T $(com32)/lib/elf32.ld .c.ls: $(CC) $(MAKEDEPS) $(CFLAGS) $(SOFLAGS) -S -o $@ $< + +%.c32: %.elf + $(OBJCOPY) --strip-debug --strip-unneeded $< $@ -- 2.7.4