A weight loss tool that executes files under UNIX strip

Source: Internet
Author: User

Unix File Compression command compress Everyone is more familiar with the compression ratio is relatively high, and the tar command used in conjunction with the use of data backup is the most appropriate. But compress compression also has shortcomings, is compressed after the file needs to use the command uncompress decompression to normal use. With the Strip command does not have this problem, it can clear the execution of unnecessary identifiers and debugging information, can reduce the file size without affecting the normal use. But unlike compress, files cannot be restored once they are strip, so strip is a weight-loss tool rather than a compression tool. Moreover, the file after being strip does not contain debugging information, you cannot use DBX to debug the program. Now let's take a look at the specific effect of the following program:
#include
Main ()
{
printf ("Hello, world/n");
}
after compiling with CC, the length is 46176 bytes, then it becomes 30648 with strip, it is reduced by 1/3, and still can execute normally. In addition to using strip, the use of shared libraries is also a way to reduce the length of file execution.
Note:
1. If the file size does not decrease, it is already strip.

2.cc compile time with "-S" parameter, the same effect

==================================================================================

Strip command explanation

Use

Reduces the size of the object file that extends the Common Object file Format (XCOFF) by removing the information that the binder and symbol debuggers use.

Grammar

Strip [- v ] [-R [-L] |-X [-L] |-T |-H |-e |-e] [- x { | | 32_64 }] [ -- ] File ...

Describe

The Strip command reduces the size of the XCOFF object file. The Strip command selectively removes line number information, relocation information, debug segments, Typchk segments, comment segments, file headers, and all or part of the symbol table from the XCOFF object file. Once you use this command, it is difficult to debug the symbols of the file, so you should usually use the strip command only on build modules that have been debugged and tested. Use the strip command to reduce the amount of storage overhead required for an object file.

For each object module, thestrip command removes the information specified by the given option. For each archive file, thestrip command removes the global symbol table from the archive.

You can use the ar-s command to restore a dropped symbol table to an archive file or library file.

The Strip command with no options removes line number information, relocation information, symbol table, debug segment, Typchk segment, and comment segment.

Sign

-E Set the f_loadonly flag in an optional header in the object file. If the object file is placed in the archive, the flag tells the binder (ld command) that the symbol in the object file should be ignored when linking to this archive.
-E Resets (closes) the f_loadonly bit in the optional header of the object file. (See the- e flag.) )
-H Removes the object file header, any optional headers, and the header portion of all segments.
Note: The symbol table information is not removed.
-L (lowercase L) to remove line number information from the object file.

-R All symbol table information is removed except for external symbols and static symbol entries. Relocation information is not removed. Also remove the debug and TYPCHK segments. This option produces an object file that can still be used as input into the link editor (ld command).
-T Removes most of the symbol table information, but does not remove the function symbol or line number information.
-V Print the version number of the strip command.
-X Removes symbol table information, but does not remove static or external symbolic information. The- x flag also removes the relocation information, so it is not possible to link to the file.
- x Mode Specifies the type of object file that should be checked for strip . mode must be one of the following:
32
Processing only 32-bit object files
64
Processing only 64-bit object files
32_64
Handles both 32-bit object files and 64-bit object files

The default value is to process 32-bit object files (ignoring 64-bit object files). You can also use the object_mode environment variable to set MODE . For example,object_mode=64 enables strip to process any 64-bit object files and ignores 32-bit object files. The- x flag resets the object_mode variable.

-- (double hyphen) interprets all parameters following the flag as file names. This allows the removal of files with names that begin with hyphens.

Exit status

The command returns the following exit values:

0 Completed successfully.
>0 Error.

Example
    1. To remove the symbol table and line number information from the a.out file, enter:
      Strip a.out
    2. To remove the object file header from the a.out file, enter:
      Strip-h a.out
    3. To remove the 32-bit and 64-bit symbol tables from the lib.a , enter:
      Strip-x 32-64 LIB.A

File
/usr/ccs/bin/strip Contains the strip command.

A weight loss tool that executes files under UNIX strip

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.