- 积分
- 185527
- 最后登录
- 2024-4-18
- 精华
- 0
- 阅读权限
- 255
- 主题
- 250
- UID
- 1004992
- 帖子
- 156603
- PB币
- 213424
- 威望
- 20481
- 贡献
- 3
- 技术
- 142
- 活跃
- 2665
幻想乡中享幸福
- UID
- 1004992
- 帖子
- 156603
- PB币
- 213424
- 贡献
- 3
- 技术
- 142
- 活跃
- 2665
|
事情起因是在楼主编译 aria2 的时候发现生成的可执行文件非常的大,居然有 58.89MB 了。
但是却发现其他Win上的可执行文件只有 5MB 左右,使用 apt-get 安装的也是很小的体积。
一番 google 之后发现可能是编译生成的可执行文件中包含了大量的符号信息,于是就试了使用 strip 来处理。
- strip /usr/local/bin/aria2c
复制代码
然后就发现可执行文件变成正常的 2.34MB了。
所以如果发现编译出的可执行文件很大,可以使用此命令来处理。
当然了,被 strip 处理后的文件不包含调试信息,也就不能调试了。
以下是 strip 命令的说明
作用
删除object文件中的符号信息
版本
- root@RPi ~ # strip -V
- GNU strip (GNU Binutils for Debian) 2.22
- Copyright 2011 Free Software Foundation, Inc.
- This program is free software; you may redistribute it under the terms of
- the GNU General Public License version 3 or (at your option) any later version.
- This program has absolutely no warranty.
复制代码
语法
strip [option] object-file [...]
描述
strip 是GNU提供用的用于删除object文件中的符号的工具。通过删除object文件中的不需要的符号信息可以达到减少object文件大小以方便文件的发布。它有助于提高逆向工程(reverse-engineer)object文件的难度。
strip 可以处理单个object文件,也可以处理.a、.so等静态与动态链接库,strip处理文件时缺省直接操作目标文件而不会生成新的文件。
选项
- root@RPi ~ # strip -h
- Usage: strip <option(s)> in-file(s)
- Removes symbols and sections from files
- The options are:
- -I --input-target=<bfdname> Assume input file is in format <bfdname>
- -O --output-target=<bfdname> Create an output file in format <bfdname>
- -F --target=<bfdname> Set both input and output format to <bfdname>
- -p --preserve-dates Copy modified/access timestamps to the output
- -R --remove-section=<name> Remove section <name> from the output
- -s --strip-all Remove all symbol and relocation information
- -g -S -d --strip-debug Remove all debugging symbols & sections
- --strip-unneeded Remove all symbols not needed by relocations
- --only-keep-debug Strip everything but the debug information
- -N --strip-symbol=<name> Do not copy symbol <name>
- -K --keep-symbol=<name> Do not strip symbol <name>
- --keep-file-symbols Do not strip file symbol(s)
- -w --wildcard Permit wildcard in symbol comparison
- -x --discard-all Remove all non-global symbols
- -X --discard-locals Remove any compiler-generated symbols
- -v --verbose List all object files modified
- -V --version Display this program's version number
- -h --help Display this output
- --info List object formats & architectures supported
- -o <file> Place stripped output into <file>
- strip: supported targets: elf32-littlearm elf32-bigarm elf32-little elf32-big plugin srec symbolsrec verilog tekhex binary ihex
复制代码 |
附件: 你需要登录才可以下载或查看附件。没有帐号?注册
-
1
查看全部评分
-
|