Date: Mon, 20 Aug 2001 00:16:54 -0700 From: Kris Kennaway <kris@obsecurity.org> To: hackers@FreeBSD.org Subject: [PATCH] install -s -s(trip-me-harder) Message-ID: <20010820001654.A32129@xor.obsecurity.org>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
What do people think about the following patch to install(1) to make
it strip additional useless (at runtime - they may be used for
debugging purposes) symbols and ELF sections from binaries at
install-time, if the '-s' option is used multiple times? This usually
saves a few tens of kilobytes per binary.
Kris
Index: xinstall.c
===================================================================
RCS file: /usr2/ncvs/src/usr.bin/xinstall/xinstall.c,v
retrieving revision 1.38.2.3
diff -u -r1.38.2.3 xinstall.c
--- xinstall.c 2001/08/01 06:48:41 1.38.2.3
+++ xinstall.c 2001/08/20 07:13:17
@@ -92,7 +92,7 @@
void install __P((char *, char *, u_long, u_int));
void install_dir __P((char *));
u_long numeric_id __P((char *, char *));
-void strip __P((char *));
+void strip __P((char *, int));
int trymmap __P((int));
void usage __P((void));
@@ -108,6 +108,7 @@
u_int iflags;
char *flags, *group, *owner, *to_name;
+ dostrip = 0;
iflags = 0;
group = owner = NULL;
while ((ch = getopt(argc, argv, "B:bCcdf:g:Mm:o:pSsv")) != -1)
@@ -156,7 +157,7 @@
safecopy = 1;
break;
case 's':
- dostrip = 1;
+ dostrip++;
break;
case 'v':
verbose = 1;
@@ -349,7 +350,7 @@
}
if (dostrip) {
- strip(tempcopy ? tempfile : to_name);
+ strip(tempcopy ? tempfile : to_name, dostrip);
/*
* Re-open our fd on the target, in case we used a strip
@@ -696,8 +697,9 @@
* use strip(1) to strip the target file
*/
void
-strip(to_name)
+strip(to_name, level)
char *to_name;
+ int level;
{
int serrno, status;
@@ -708,7 +710,12 @@
errno = serrno;
err(EX_TEMPFAIL, "fork");
case 0:
- execlp("strip", "strip", to_name, (char *)NULL);
+ if (level > 1)
+ execlp("strip", "strip", "-s", "-R", ".comment",
+ "-R", ".note", "-N", "gcc2_compiled",
+ to_name, (char *)NULL);
+ else
+ execlp("strip", "strip", to_name, (char *)NULL);
err(EX_OSERR, "exec(strip)");
default:
if (wait(&status) == -1 || status) {
[-- Attachment #2 --]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (FreeBSD)
Comment: For info see http://www.gnupg.org
iD8DBQE7gLllWry0BWjoQKURAg2dAKCtt4dPOqlM4nq7kaDI32UePvAsOQCbBrin
wkgPf7WRzRn8u9fNGysBao0=
=7vkE
-----END PGP SIGNATURE-----
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010820001654.A32129>
