Strip command usage

Source: Internet
Author: User
Tags uncompress
Purpose

By removing the information used by the binding program and the symbolic debugging program, you can reduce the size of the object file that extends the Common Object File Format (xcoff.

Syntax

Strip [-V] [-R [-L]
|-X [-L]
|-T |-H |-E]
[-X {32 | 64 | 32_64}] [--] file...

Description

The strip command reduces the size of the xcoff object file. The strip command selectively removes line number information, relocation information, debugging segments, typchk segments, comment segments, file headers, and all or part of symbol tables from the xcoff object file. Once you use this command, it is difficult to debug the symbols of the file. Therefore, the strip command should be used only on the generated modules that have been debugged and tested. Use the Strip command to reduce the storage overhead required for object files.

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

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

The strip command without options removes line number information, relocation information, symbol table, debugging segment, typchk segment, and Comment Segment.

Flag

-E Set the f_loadonly flag in the optional Header of the object file. If the object file is placed in the archive, this flag notifies the binding Program (LD command) that the symbols in the object file should be ignored during the link to this archive.
-E Reset (close) The f_loadonly bit in the optional Header of the object file. (See-e flag .)
-H Remove the object file header, any optional headers, And the headers of all segments.

Note: Do not remove the symbol table information.

-L (Lower case l) removes the row number information from the object file.

 

-R Except external and static symbol entries, all symbol table information is removed. The relocation information is not excluded. Besides the debugging and typchk segments. This option generates an object file, which can still be used as input to the link Editor (LD command.
-T Except most symbol table information, function symbols or row number information are not excluded.
-V Print the Strip command version number.
-X Except the symbol table information, static or external symbol information is not removed. The-x flag removes the relocation information and therefore cannot be linked to the file.
-X Mode Specifies the object file type of strip. Mode must be one of the following:

32
Only 32-bit object files are processed
64
Only 64-bit object files are processed
32_64
Processing both 32-bit object files and 64-bit object files

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

-- (Dual-concatenation) All parameters following the flag are interpreted as file names. This allows you to remove files whose names start with a hyphen.

Exit status

This command returns the following exit value:

0 Completed successfully.
> 0 Error.

Example
  1. To remove the symbol table and row number information in the. out file, enter:
    strip a.out
  2. To remove the object file header in the. out file, enter:
    strip -H a.out
  3. To remove the 32-bit and 64-bit symbol tables in Lib. A, enter:
    strip -X 32-64 lib.a

File
/Usr/CCS/bin/Strip Contains the Strip command.

 

 

 

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

Strip
-

The compress command for File compression in UNIX is familiar to everyone. It has a high compression ratio. It is most appropriate to use it with the tar command for data backup. However, compress compression also has a disadvantage, that is, the compressed file must be decompressed with the uncompress command before it can be used properly. The strip command does not solve this problem. It can clear unnecessary identifiers and debugging information in the execution file and reduce the file size without affecting normal use. Different from compress, strip cannot be restored once files are strip, so strip is a weight loss tool rather than a compression tool. Besides, if the Strip file does not contain debugging information, DBX cannot be used to debug the program. Now let's take a look at the specific effect. Let's look at the following program:
# Include
Main ()
{
Printf ("Hello, world/N ");
}
After compiling with CC, the length is 46176 bytes. After strip is used, it is changed to 30648, which is reduced by 1/3 and can still be executed normally. In addition to strip, shared libraries are also used to reduce the execution file length.
Note:
1. If the file size is not reduced, strip has passed.
2. added the "-s" parameter during CC compilation, which has the same effect.
Some space-saving method:
That is, you can write a zexec script for a single large executable file. The script below is only for/usr/bin/CC
Uncompress./CC. Z
Mv cc/tmp
CD/tmp
./CC

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.