• Home
  • About
    • Road to Coding photo

      Road to Coding

      只要那一抹笑容尚存, 我便心无旁骛

    • Learn More
    • Email
    • Github
  • Posts
    • All Posts
    • All Tags

Binutils の size

27 May 2018

既然说到size命令,这是一个Linux下,用于查看可执行文件各段size的工具

SIZE(1)                          GNU Development Tools                          SIZE(1)

NAME
       size - list section sizes and total size.
    #size - 列出各section的大小以及总大小

SYNOPSIS        # 简介 [sɪˈnɒpsɪs]
       size [-A|-B|--format=compatibility]
            [--help]
            [-d|-o|-x|--radix=number]
            [--common]
            [-t|--totals]
            [--target=bfdname] [-V|--version]
            [objfile...]

DESCRIPTION           #命令描述
       The GNU size utility lists the section sizes---and the total size---for each of
       the object or archive files objfile in its argument list.  By default, one line
       of output is generated for each object file or each module in an archive.
	   
    # GNU size效用是列出section的大小 --- 和总大小---对于每个目标文件 或 静态链接库参数列表       
	# 中目标文件. 默认情况下, 每一行的输出被各个目标文件所隔离开,或是静态链接库中的模块

       objfile... are the object files to be examined.  If none are specified, the file
       "a.out" will be used.
	   
    # 参数[object...]是要被检测的目标文件(可执行文件). 如果没有被指定, 会使用"a.out"文件

OPTIONS    #参数: 选项
       The command line options have the following meanings:
	   
    # 命令行选项有以下的含义:

       -A
       -B
       --format=compatibility # 兼容性 [kəmˌpætəˈbɪləti]
           Using one of these options, you can choose whether the output from GNU size
           resembles  # 与..想像  [rɪˈzembl] 
		   output from System V size (using -A, or --format=sysv), or
           Berkeley size (using -B, or --format=berkeley).  The default is the one-line
           format similar to Berkeley's.
		   
	# 使用这些其中之一的选项, 你可以选择GNU输出是使用UNIX 第五版(使用选项 -A, 或者选项   
	# --format=sysv), 或者伯克利(即BSD系列)(使用选项-B, 或者选项 --format=berkeley). 	 # 默认是一行输出的格式与伯克利模式相似 

           Here is an example of the Berkeley (default) format of output from size:
	# 这里是伯克利格式的输出示例

                   $ size --format=Berkeley ranlib size
                   text    data    bss     dec     hex     filename
                   294880  81920   11592   388392  5ed28   ranlib
                   294880  81920   11888   388688  5ee50   size

           This is the same data, but displayed closer to System V conventions:
	# 这是相同的数据, 但是显示方式更接近于System V 转换:

                   $ size --format=SysV ranlib size
                   ranlib  :
                   section         size         addr
                   .text         294880         8192
                   .data          81920       303104
                   .bss           11592       385024
                   Total         388392

                   size  :
                   section         size         addr
                   .text         294880         8192
                   .data          81920       303104
                   .bss           11888       385024
                   Total         388688

       --help
           Show a summary of acceptable arguments and options.
	# 显示可接受的参数和选项摘要     summary  [ˈsʌməri] 

       -d
       -o
       -x
       --radix=number
           Using one of these options, you can control whether the size of each section
           is given in decimal (-d, or --radix=10); octal (-o, or --radix=8); or
           hexadecimal (-x, or --radix=16).  In --radix=number, only the three values
           (8, 10, 16) are supported.  The total size is always given in two radices;
           decimal and hexadecimal for -d or -x output, or octal and hexadecimal if
           you're using -o.
		   
	# 使用下面这些选项, 你可以控制每一个section的大小是以十进制, 八进制, 或者十六进制给
	# 出 . 在 --radix=number选项中, 只支持(8, 10, 16)进制三种取值. 总大小总是以两种形
	# 式给出 十进制和十六进制 使用 -d 或 -x 输出. 或者八进制和十六进制如果你使用-o选项

       --common
           Print total size of common symbols in each file.  When using Berkeley format
           these are included in the bss size.
		   
	# 打引出每个文件中的一般符号, 当使用伯克利格式时(-B选项), 这些是包含在bss的大小中的

       -t
       --totals
           Show totals of all objects listed (Berkeley format listing mode only).
		   
	# 显示所有被列出的目标文件的总计 (仅限伯克利格式的模式选择)

       --target=bfdname
           Specify that the object-code format for objfile is bfdname.  This option may
           not be necessary; size can automatically recognize many formats.

	# specify 指定 [ˈspesɪfaɪ], 指定目标文件代码是使用bfdname的格式. 此选项不是必需的;   
	# size可以自动分辨许多格式
       -V
       --version
           Display the version number of size.
		   
	# 显示size命令的版本号
       @file
           Read command-line options from file.  The options read are inserted in place
           of the original @file option.  If file does not exist, or cannot be read,
           then the option will be treated literally, and not removed.
		   
	# 从文件阅读命令行选项. 选项阅读是被嵌入在 @file选项的起源之处的. 如果此文件不存在.   
	# 或者不能被读取, 那么选项将被按照字面意思解释, 不会被移除.                         
	# literally [ˈlɪtərəli] 逐字地
		   
           Options in file are separated by whitespace.  A whitespace character may be
           included in an option by surrounding the entire option in either single or
           double quotes.  Any character (including a backslash) may be included by
           prefixing the character to be included with a backslash.  The file may
           itself contain additional @file options; any such options will be processed
           recursively.
		   
	# 选项在文件中空白分开, (意译: 选项使用时被空格分开). 一个空白字符可以被包含在一个选项中,
	# 依靠整个选项周围是单个或双引用(意译: 使用引用时, 可以将空白字符包含在选项中). 
	# 任何字符(包括反斜线 \ ) 都可能被包含,靠字符的前缀靠使用反斜线. 
	# 这个文件其自身包含@file选项; 任何这样的选项将会被递归调用
	# prefix 前缀的 [ˈpri:fɪks]
	# recursive 回归的, 递归的,[rɪˈkɜ:sɪv] 

SEE ALSO
       ar(1), objdump(1), readelf(1), and the Info entries for binutils.
	   
	# 推荐查阅, ar, objdump, readelf 同时info binutils(GNU二进制工具集)的细节

COPYRIGHT
       Copyright (c) 1991-2017 Free Software Foundation, Inc.
	   
	# 1991- 2017 自由软件基金会

       Permission is granted to copy, distribute and/or modify this document under the
       terms of the GNU Free Documentation License, Version 1.3 or any later version
       published by the Free Software Foundation; with no Invariant Sections, with no
       Front-Cover Texts, and with no Back-Cover Texts.  A copy of the license is
       included in the section entitled "GNU Free Documentation License".

	# 上面这些, 有兴趣,去了解GNU执照, 不多说了
binutils-2.29                          2017-07-24   # size亦属于GNU二进制工具包                              SIZE(1)

-A Option

-B Option

--format

-t Option

-V Option

如有疑问, 或者有任何新发现, 可以随时交流, 此系列不是近仅作翻译, 有值得关注的点会谈谈其他的

size直接看man文档已经很足够了, 我们下次再见(ಡωಡ)



Binuntils Share Tweet +1