Skip site navigation (1)Skip section navigation (2)
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

--LQksG6bCIzRHxTLp
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
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));
=20
@@ -108,6 +108,7 @@
 	u_int iflags;
 	char *flags, *group, *owner, *to_name;
=20
+	dostrip =3D 0;
 	iflags =3D 0;
 	group =3D owner =3D NULL;
 	while ((ch =3D getopt(argc, argv, "B:bCcdf:g:Mm:o:pSsv")) !=3D -1)
@@ -156,7 +157,7 @@
 			safecopy =3D 1;
 			break;
 		case 's':
-			dostrip =3D 1;
+			dostrip++;
 			break;
 		case 'v':
 			verbose =3D 1;
@@ -349,7 +350,7 @@
 	}
=20
 	if (dostrip) {
-		strip(tempcopy ? tempfile : to_name);
+		strip(tempcopy ? tempfile : to_name, dostrip);
=20
 		/*
 		 * 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;
=20
@@ -708,7 +710,12 @@
 		errno =3D 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) =3D=3D -1 || status) {


--LQksG6bCIzRHxTLp
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (FreeBSD)
Comment: For info see http://www.gnupg.org

iD8DBQE7gLllWry0BWjoQKURAg2dAKCtt4dPOqlM4nq7kaDI32UePvAsOQCbBrin
wkgPf7WRzRn8u9fNGysBao0=
=7vkE
-----END PGP SIGNATURE-----

--LQksG6bCIzRHxTLp--

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010820001654.A32129>