Purpose
By removing the information used by the binding program and the symbolic debugging program, you can reduce the size of object files in the extended public 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, staring segments, file headers, and all or part of symbol tables from the xcoff object file. Once you use this command, it is very difficult to debug the file symbols. Therefore, you should generally only use the Strip command on the Generation modules that have been debugged and tested by the pipeline. 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 staring 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). 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. (Please refer to the-e mark .) |
-H |
Remove the object file header, the 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. Remove the debugging and typchk segments at the same time. 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. |
-X |
Except the symbol table information, static or external symbol information is not removed. The-X mark removes the relocation information at the same time, so it is impossible to link to the file. |
-X Mode |
Specifies the object file type of strip. The mode must be one of the following:
-
32
-
Only 32-bit object files are processed
-
64
-
Only processing 64-bit object files
-
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 64-bit object files and ignore 32-bit object files. -The-x flag resets the object_mode variable. |
-- |
(Dual-concatenation) the total number of bytes that follow the flag is interpreted as the file name. In this case, we agree to remove the file whose name starts with a hyphen. |
Exit status
This command returns the following exit value:
0 |
Completed successfully. |
> 0 |
Error. |
Demo
- To remove the symbol table and row number information in the. out file, enter:
strip a.out
- To remove the object file header in the. out file, enter:
strip -H a.out
- 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 |
Including Strip commands. |
========================================================== ========================================================== =
Strip, a tool for running files in UNIX
-
In UNIX, the File compression command compress is familiar to everyone. It has a higher compression ratio than the compression ratio. It is best 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 normally. The strip command does not solve this problem. It can clear unnecessary identifiers and debugging information in the running 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. In addition, if the Strip file does not include debugging information, DBX cannot be used to debug the program. Now let's take a look at the detailed effect and look at the next 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 run normally. In addition to strip, shared libraries are also used to reduce the running file length.
Note:
1. If the file size is not reduced, strip has passed.
2. added the "-s" number of bytes during CC compilation, which has the same effect.
Some space-saving method:
That is, you can write a zexec script for a single Executable File larger than the executor. The following script is only for/usr/bin/CC
Uncompress./CC. Z
Mv cc/tmp
CD/tmp
./CC
How to Use the Strip command