sstrip is a small utility that removes an ELF file's section header
table, and any contents that are not part of the ELF file's memory
image.

Most ELF executables are built with both a program header table and a
section header table. However, only the former is required in order
for the OS to load, link and execute a program. sstrip extracts the
ELF header and the program header table and its contents, and leaves
everything else in the bit bucket.

It should be noted that the GNU bfd library is (understandably)
dependent on the section header table as an index to the file's
contents. Thus, an executable file that has been stripped by sstrip
cannot be used with gdb, objdump, or any other program based upon the
bfd library, at all. In fact, the program will not even recognize the
file as a valid executable. (This limitation is noted in the source
code comments for bfd, and is marked "FIXME", so this may change at
some future date. However, I would imagine that it is a pretty
low-priority item, as executables without a section header table are
rare in the extreme.)

Shared library files may also be stripped by sstrip. Such a library
will still function; however, it will no longer be possible for a
compiler to link a new program against it.

As an added bonus, sstrip also tries to removes trailing zero bytes
from the contents of loadable program header table entries. (This
normally cannot be done with an executable that has a section header
table.)  Finally, if the program header table contains any entries of
type PT_NOTE, the contents of that segment will be removed from the
file, and the table entry is changed to type PT_NULL.

PLEASE note that sstrip is a very simplistic program, and should not
be used incautiously, if it is used at all. sstrip depends upon the
common practice of putting the parts of the file that contribute to
the memory image at the front, and the remaining material at the
end. This permits it to discard the latter material without affecting
file offsets and memory addresses in what remains. However, this is
merely common practice, done for conveniece, and the ELF standard
permits files to be organized in almost any order. While sstrip tries
to be intelligent about its surgical procedures, the problem is that
loadable segments of the file need to be loaded at addresses that are
equal to their file offset, modulo the page size.  Thus, if sstrip is
given a file in which (say) the section header table appears above the
data segment, it will most likely destroy this equivalence, and
blissfully render the executable unfit for use. While this simplistic
procedure succeeds more often than not, it is not meant to be taken
seriously.
