From 9dcf0c5ecb7ebd3977bbdaa74f8e6ea46d4e3d3b Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sun, 25 Mar 2018 09:39:18 -0600 Subject: [PATCH] apps/examples/elf: Use strip command to make ELF binaries MUCH smaller. --- examples/elf/tests/Makefile | 17 ++++++++++++----- examples/elf/tests/mkdirlist.sh | 4 ++-- examples/posix_spawn/filesystem/Makefile | 1 + 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/examples/elf/tests/Makefile b/examples/elf/tests/Makefile index e7dc9898e..165dfaf05 100644 --- a/examples/elf/tests/Makefile +++ b/examples/elf/tests/Makefile @@ -66,7 +66,8 @@ DIRLIST_HDR = $(TESTS_DIR)/dirlist.h SYMTAB_SRC = $(TESTS_DIR)/symtab.c ifeq ($(CONFIG_EXAMPLES_ELF_ROMFS),y) - FSIMG_DIR = $(TESTS_DIR)/romfs + FSIMG_SUBDIR = romfs + FSIMG_DIR = $(TESTS_DIR)/$(FSIMG_SUBDIR) ROMFS_IMG = $(TESTS_DIR)/romfs.img FSIMG_HDR = $(TESTS_DIR)/romfs.h else @@ -74,7 +75,8 @@ else GENCROMFSSRC = gencromfs.c GENCROMFSEXE = gencromfs$(EXEEXT) - FSIMG_DIR = $(TESTS_DIR)/cromfs + FSIMG_SUBDIR = cromfs + FSIMG_DIR = $(TESTS_DIR)/$(FSIMG_SUBDIR) FSIMG_HDR = $(TESTS_DIR)/cromfs.h endif @@ -98,6 +100,11 @@ build: $(foreach DIR, $(BUILD_SUBDIRS), $(DIR)_build) # Install each program in the file system image directory install: $(foreach DIR, $(BUILD_SUBDIRS), $(DIR)_install) +ifneq ($(STRIP),) +ifneq ($(CONFIG_DEBUG_SYMBOLS),y) + $(Q) $(STRIP) $(wildcard $(FSIMG_SUBDIR)/*) +endif +endif # Create the file system image directory @@ -122,13 +129,13 @@ $(FSIMG_HDR) : $(ROMFS_IMG) else # Make sure that the NuttX gencromfs tool has been built -$(NXTOOLDIR)$(DELIM)$(GENCROMFSEXE): $(NXTOOLDIR)$(DELIM)$(GENCROMFSSRC) +$(NXTOOLDIR)/$(GENCROMFSEXE): $(NXTOOLDIR)/$(GENCROMFSSRC) $(Q) $(MAKE) -C $(NXTOOLDIR) -f Makefile.host $(GENCROMFSEXE) # Create the cromfs.h header file from the populated cromfs directory -$(FSIMG_HDR) : populate $(NXTOOLDIR)$(DELIM)$(GENCROMFSEXE) - $(Q) $(NXTOOLDIR)$(DELIM)$(GENCROMFSEXE) $(FSIMG_DIR) $(FSIMG_HDR) +$(FSIMG_HDR) : populate $(NXTOOLDIR)/$(GENCROMFSEXE) + $(Q) $(NXTOOLDIR)/$(GENCROMFSEXE) $(FSIMG_DIR) $(FSIMG_HDR) endif diff --git a/examples/elf/tests/mkdirlist.sh b/examples/elf/tests/mkdirlist.sh index c790e74c4..8076072d2 100755 --- a/examples/elf/tests/mkdirlist.sh +++ b/examples/elf/tests/mkdirlist.sh @@ -1,10 +1,10 @@ #!/bin/bash -usage="Usage: %0 " +usage="Usage: %0 " dir=$1 if [ -z "$dir" ]; then - echo "ERROR: Missing " + echo "ERROR: Missing " echo "" echo $usage exit 1 diff --git a/examples/posix_spawn/filesystem/Makefile b/examples/posix_spawn/filesystem/Makefile index 7112a9032..0967242b5 100644 --- a/examples/posix_spawn/filesystem/Makefile +++ b/examples/posix_spawn/filesystem/Makefile @@ -63,6 +63,7 @@ redirect/redirect: $(Q) $(MAKE) -C redirect redirect TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)" # Create the romfs.img file from the romfs directory +# REVISIT: ELF binaries should be stripped so that they are not so big $(ROMFS_IMG): hello/hello redirect/redirect testdata.txt $(ROMFS_DIR) $(Q) $(MAKE) -C hello install TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" ROMFS_DIR="$(ROMFS_DIR)"