Strip (Unix)

Last updated
strip
Original author(s) Dennis Ritchie
(AT&T Bell Laboratories)
Developer(s) Various open-source and commercial developers
Initial releaseJune 12, 1972;52 years ago (1972-06-12)
Written in C
Operating system Unix, Unix-like, Plan 9, Microsoft Windows
Platform Cross-platform
Type Command
License Plan 9: MIT License

In Unix, Plan 9, and Unix-like operating systems, the strip program is a command-line utility used to remove non-essential information from executable binary programs and object files. This information, which is not required for execution, typically includes debugging data, symbol tables, relocation information, and other metadata. Its primary purpose is to reduce the file size of the binary executable and potentially increase performance. The output of this process is known as a stripped binary.

Contents

Description

strip is a GNU binary utility that is used to remove information in a compiled binary or object file that is not needed for its execution. This information typically includes debugging information and symbol tables; however, the exact scope of the changes made to the binary is left to the discretion of the program's implementer by using the command-line options. [1]

Using strip can enhance the security of a binary by making it more difficult to reverse-engineer. The absence of symbol and debugging information complicates the program analysis of the binary.

The effect of strip can also be achieved directly by using the compiler or linker to perform the same process. A compiler is a program that translates source code written in a high-level programming language (like C or C++) into machine code that the computer’s processor can execute. A linker, on the other hand, takes one or more object files generated by the compiler and combines them into a single executable file, resolving any symbol references between them. [2]

For example, in the GNU Compiler Collection (GCC), this is done by using the "-s” option with gcc. This tells the linker to remove debugging information and symbols during the linking process, resulting in a smaller, stripped executable. [2]

The GNU Project ships an implementation of strip as part of the GNU Binutils package. strip has been ported to other operating systems including Microsoft Windows.

See also

Related Research Articles

<span class="mw-page-title-main">Bash (Unix shell)</span> GNU replacement for the Bourne shell

Bash, short for Bourne-Again SHell, is a shell program and command language supported by the Free Software Foundation and first developed for the GNU Project by Brian Fox. Designed as a 100% free software alternative for the Bourne shell, it was initially released in 1989. Its moniker is a play on words, referencing both its predecessor, the Bourne shell, and the concept of rebirth.

<span class="mw-page-title-main">Executable and Linkable Format</span> Standard file format for executables, object code, shared libraries, and core dumps.

In computing, the Executable and Linkable Format is a common standard file format for executable files, object code, shared libraries, and core dumps. First published in the specification for the application binary interface (ABI) of the Unix operating system version named System V Release 4 (SVR4), and later in the Tool Interface Standard, it was quickly accepted among different vendors of Unix systems. In 1999, it was chosen as the standard binary file format for Unix and Unix-like systems on x86 processors by the 86open project.

<span class="mw-page-title-main">GNU Debugger</span> Source-level debugger

The GNU Debugger (GDB) is a portable debugger that runs on many Unix-like systems and works for many programming languages, including Ada, Assembly, C, C++, D, Fortran, Haskell, Go, Objective-C, OpenCL C, Modula-2, Pascal, Rust, and partially others.

<span class="mw-page-title-main">Linker (computing)</span> Computer program which combines multiple object files into a single file

In computing, a linker or link editor is a computer system program that takes one or more object files and combines them into a single executable file, library file, or another "object" file.

In software development, Make is a command-line interface software tool that performs actions ordered by configured dependencies as defined in a configuration file called a makefile. It is commonly used for build automation to build executable code from source code. But, not limited to building, Make can perform any operation available via the operating system shell.

The Common Object File Format (COFF) is a format for executable, object code, and shared library computer files used on Unix systems. It was introduced in Unix System V, replaced the previously used a.out format, and formed the basis for extended specifications such as XCOFF and ECOFF, before being largely replaced by ELF, introduced with SVR4. COFF and its variants continue to be used on some Unix-like systems, on Microsoft Windows, in UEFI environments and in some embedded development systems.

An object file is a file that contains machine code or bytecode, as well as other data and metadata, generated by a compiler or assembler from source code during the compilation or assembly process. The machine code that is generated is known as object code.

<span class="mw-page-title-main">MinGW</span> Free and open-source software for developing applications in Microsoft Windows

MinGW, formerly mingw32, is a free and open source software development environment to create Microsoft Windows applications.

The archiver, also known simply as ar, is a Unix utility that maintains groups of files as a single archive file. Today, ar is generally used only to create and update static library files that the link editor or linker uses and for generating .deb packages for the Debian family; it can be used to create archives for any purpose, but has been largely replaced by tar for purposes other than static libraries. An implementation of ar is included as one of the GNU Binutils.

In computer science, a symbol table is a data structure used by a language translator such as a compiler or interpreter, where each identifier, constant, procedure and function in a program's source code is associated with information relating to its declaration or appearance in the source. In other words, the entries of a symbol table store the information related to the entry's corresponding symbol.

nm is a Unix command used to dump the symbol table and their attributes from a binary executable file.

A dynamic-link library (DLL) is a shared library in the Microsoft Windows or OS/2 operating system.

strings (Unix)

In computer software, strings is a program in Unix, Plan 9, Inferno, and Unix-like operating systems that finds and prints the strings of printable characters in files. The files can be of regular text files or binary files such as executables. It can be used on object files and core dumps. strings is mainly useful for determining the contents of non-text files.

<span class="mw-page-title-main">GNU Binutils</span> GNU software development tools for executable code

The GNU Binary Utilities, or binutils, is a collection of programming tools maintained by the GNU Project for working with executable code including assembly, linking and many other development operations.

Interprocedural optimization (IPO) is a collection of compiler techniques used in computer programming to improve performance in programs containing many frequently used functions of small or medium length. IPO differs from other compiler optimizations by analyzing the entire program as opposed to a single function or block of code.

A weak symbol denotes a specially annotated symbol during linking of Executable and Linkable Format (ELF) object files. By default, without any annotation, a symbol in an object file is strong. During linking, a strong symbol can override a weak symbol of the same name. In contrast, in the presence of two strong symbols by the same name, the linker resolves the symbol in favor of the first one found. This behavior allows an executable to override standard library functions, such as malloc(3). When linking a binary executable, a weakly declared symbol does not need a definition. In comparison, a declared strong symbol without a definition triggers an undefined symbol link error.

The tsort program is a command line utility on Unix and Unix-like platforms, that performs a topological sort on its input. As of 2017, it is part of the POSIX.1 standard.

A debug symbol is a special kind of symbol that attaches additional information to the symbol table of an object file, such as a shared library or an executable. This information allows a symbolic debugger to gain access to information from the source code of the binary, such as the names of identifiers, including variables and routines.

Gcov is a source code coverage analysis and statement-by-statement profiling tool. Gcov generates exact counts of the number of times each statement in a program is executed and annotates source code to add instrumentation. Gcov comes as a standard utility with the GNU Compiler Collection (GCC) suite.

Mingw-w64 is a free and open-source suite of developments tools that generate Portable Executable (PE) binaries for Microsoft Windows. It was forked in 2005–2010 from MinGW.

References

  1. "Linux Strip Command". www.computerhope.com. Retrieved 2024-10-01.
  2. 1 2 "What is the difference between "gcc -s" and a "strip" command?". Stack Overflow. Retrieved 2024-10-01.