Date: Mon, 3 Mar 2008 21:02:19 +0100 From: Ed Schouten <ed@80386.nl> To: FreeBSD Current <freebsd-current@freebsd.org> Subject: Yet another BSD licensed replacement: size(1) Message-ID: <20080303200219.GF80576@hoeg.nl>
next in thread | raw e-mail | index | archive | help
--gm5TwAJMO0F2iVRz Content-Type: multipart/mixed; boundary="gdTfX7fkYsEEjebm" Content-Disposition: inline --gdTfX7fkYsEEjebm Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello, Today I found out we have a utility in FreeBSD that's 300 KB's in size and is only used to display some fancy numbers, called size(1). (Yeah, 300 KB - it is statically linked against libbfd.) I thought it would be possible to rewrite size(1) to use libelf. The result: GNU size(1); | $ size /usr/bin/size | text data bss dec hex filename | 309202 1524 16964 327690 5000a size My size(1): | $ ./size size | text data bss dec hex filename | 5209 340 44 5593 15d9 size So far I've implemented all common features supported by the GNU version, except one: when you use size -A (the `System V format'), it doesn't calculate the relocated addresses yet. It now prints 0xdeadc0de, but this has to be fixed. I haven't tested the utility on any 64-bit systems yet and I know it will probably won't work there yet, but I'll look at these issues soon. When finished, it should be a drop-in replacement. The Berkeley format is exactly the same as the original GNU version. The System V format should be almost the same, except for some whitespace. I've attached the code to this message. --=20 Ed Schouten <ed@fxq.nl> WWW: http://g-rave.nl/ --gdTfX7fkYsEEjebm Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=Makefile PROG= size LDADD= -lelf BINDIR= /usr/bin .include <bsd.prog.mk> --gdTfX7fkYsEEjebm Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="size.1" .\"- .\" Copyright (c) 2008 Ed Schouten <ed@fxq.nl> .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" $FreeBSD$ .\" .Dd March 3, 2008 .Dt SIZE 1 .Os .Sh NAME .Nm size .Nd list section sizes of ELF files .Sh SYNOPSIS .Nm .Op Fl A | B .Op Fl d | o | x .Op Fl t .Ar .Sh DESCRIPTION For each operand, .Nm displays the sizes of the read-only sections of the ELF file (text), the read-write sections (data) and the zero-initialized sections (bss). This format is referred to as the Berkeley format, which is shown by default. .Pp This version of .Nm also supports the System V format, which shows the sizes and load addresses of all sections within the ELF file. .Pp The following options are available: .Bl -tag -width indent .It Fl A Show output using the System V format. .It Fl B Show output using the Berkeley format. .It Fl d Display sizes as decimal numbers. .It Fl o Display sizes as octal numbers. When enabled, the .Em dec column in the Berkeley format is replaced by a column which displays the size in octal. .It Fl x Display sizes as hexadecimal numbers. .It Fl t When using the Berkeley format, show the total size for all ELF files at the bottom. .Sh EXIT STATUS .Ex -std .Sh COMPATIBILITY This utility implements most standard options that are implemented in the GNU .Nm utility. Unlike the GNU version, this utility only supports decimal, octal and hexadecimal radices. .Sh SEE ALSO .Xr objdump 1 , .Xr readelf 1 , .Sh HISTORY In .Fx 8.0 , .An "Ed Schouten" Aq ed@80386.nl reimplemented .Nm using the .Lb libelf . --gdTfX7fkYsEEjebm-- --gm5TwAJMO0F2iVRz Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (FreeBSD) iEYEARECAAYFAkfMWUsACgkQ52SDGA2eCwULiACfex1FCR18bgFj30xd2CG6Zutd WPMAn3fJ2vcUkBoKdd0vzlYi5DzFBTIX =3koJ -----END PGP SIGNATURE----- --gm5TwAJMO0F2iVRz--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20080303200219.GF80576>