mirror of
https://github.com/deater/tb1.git
synced 2024-12-22 13:29:48 +00:00
.. | ||
asm_elf_alpha.h | ||
asm_elf_arm.h | ||
asm_elf_armbe.h | ||
asm_elf_armv5tel.h | ||
asm_elf_avr32.h | ||
asm_elf_blackfin.h | ||
asm_elf_crisv32.h | ||
asm_elf_frv.h | ||
asm_elf_h8300.h | ||
asm_elf_i686.h | ||
asm_elf_ia64.h | ||
asm_elf_m32r.h | ||
asm_elf_m68k.h | ||
asm_elf_microblaze.h | ||
asm_elf_mips64.h | ||
asm_elf_mips.h | ||
asm_elf_mipsel.h | ||
asm_elf_mn10300.h | ||
asm_elf_parisc.h | ||
asm_elf_ppc.h | ||
asm_elf_RiSC.h | ||
asm_elf_s390.h | ||
asm_elf_sh3.h | ||
asm_elf_sparc64.h | ||
asm_elf_sparc.h | ||
asm_elf_vax.h | ||
asm_elf_x86_64.h | ||
asm_elf_xtensa.h | ||
Makefile | ||
README | ||
README.MORE | ||
sstrip.c |
sstrip is a small utility that removes the contents at the end of an ELF file that are not part of the program'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 attempts to extract the ELF header, the program header table, and its contents, leaving everything else in the bit bucket. It can only remove parts of the file that occur at the end, after the parts to be saved. However, this almost always includes the section header table, and occasionally a few random sections that are not used when running a program. 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 no section header table 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.) This probably also explains why strip doesn't offer the option to do this. Shared library files may also have their section header table removed. 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 end of the file. (This normally cannot be done with an executable that has a section header table.) sstrip is a very simplistic program. It 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. Of course, the ELF standard permits files to be organized in almost any order, so if a pathological linker decided to put its section headers at the top, sstrip would be useless on such executables.