AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / unix / 问题 / 434561
Accepted
masec
masec
Asked: 2018-03-31 11:32:44 +0800 CST2018-03-31 11:32:44 +0800 CST 2018-03-31 11:32:44 +0800 CST

大小指令单位?

  • 772

令人惊讶的是,我找不到大小命令单位。例如在

$ size cat
   text    data     bss     dec     hex filename
  29150    1148     416   30714    77fa cat

我想知道 cat 程序的文本大小是多少。那么它是29150字节吗?

linux
  • 1 1 个回答
  • 2755 Views

1 个回答

  • Voted
  1. Best Answer
    jesse_b
    2018-03-31T11:44:16+08:002018-03-31T11:44:16+08:00

    似乎 GNU 大小手册没有指定,但是我相信它们对于所有版本的大小都是以字节为单位的。

    这是苹果size手册:

    SIZE(1)                                                                                                                               SIZE(1)
    
    NAME
           size - print the size of the sections in an object file
    
    SYNOPSIS
           size [ option ... ] [ object ... ]
    
    DESCRIPTION
           Size  (without the -m option) prints the (decimal) number of bytes required by the __TEXT, __DATA and __OBJC segments.  All other seg-
           ments are totaled and that size is listed in the `others' column.  The final two columns is the sum in decimal and hexadecimal.  If no
           file is specified, a.out is used.
    
           The options to size(1) are:
    
           -      Treat the remaining arguments as name of object files not options to size(1).
    
           -m     Print  the  sizes  of the Mach-O segments and sections as well as the total sizes of the sections in each segment and the total
                  size of the segments in the file.
    
           -l     When used with the -m option, also print the addresses and offsets of the sections and segments.
    
           -x     When used with the -m option, print the values in hexadecimal (with leading 0x's) rather than decimal.
    
           -arch arch_type
                  Specifies the architecture, arch_type, of the file for size(1) to operate on when the file is a universal file.   (See  arch(3)
                  for the currently know arch_types.)  The arch_type can be "all" to operate on all architectures in the file.  The default is to
                  display only the host architecture, if the file contains it; otherwise, all architectures in the file are shown.
    
    SEE ALSO
           otool(1)
    
    BUGS
           The size of common symbols can't be reflected in any of the numbers for relocatable object files.
    
    Apple Computer, Inc.                                            July 28, 2005                                                         SIZE(1)
    

    和 SmartOSsize手册:

    SIZE(1)                          User Commands                         SIZE(1)
    
    
    
    NAME
           size - print section sizes in bytes of object files
    
    SYNOPSIS
           size [-f] [-F] [-n] [-o] [-V] [-x] filename...
    
    
    DESCRIPTION
           The size command produces segment or section size information in bytes
           for each loaded section in ELF object files. size prints out  the size
           of the text, data, and bss (uninitialized data) segments (or  sections)
           and their total.
    
    
           size processes ELF object files entered on the command line. If an
           archive file is input to the size command, the information for each
           object file in the archive is displayed.
    
    
           When calculating segment information, the size command prints out the
           total file size of the non-writable segments, the total file size of
           the writable segments, and the total memory size of the writable
           segments minus the total  file size of the writable segments.
    
    
           If it cannot calculate segment information, size calculates section
           information. When calculating section  information, it prints out the
           total size of sections that are allocatable,  non-writable, and not
           NOBITS, the total size of the sections that are allocatable,  writable,
           and not NOBITS, and the total size of the writable sections of type
           NOBITS.  NOBITS sections do not actually take up space in the filename.
    
    
           If size cannot calculate either segment or section information, it
           prints an error message and stops processing the file.
    
    OPTIONS
           The following options are supported:
    
           -f
                 Prints out the size of each allocatable section, the name of the
                 section, and the total of the section sizes. If there is no
                 section data, size prints out an error message and stops
                 processing the file.
    
    
           -F
                 Prints out the size of each loadable segment, the permission
                 flags of the segment, then the total of the loadable segment
                 sizes. If there is no segment data, size prints an error message
                 and stops processing the file.
    
    
           -n
                 Prints out non-loadable segment or non-allocatable section sizes.
                 If segment data exists, size prints out the memory size of each
                 loadable segment or file size of each non-loadable segment, the
                 permission flags, and the total size of the segments. If there is
                 no segment data, size prints out, for each allocatable and non-
                 allocatable section, the memory size, the section name,  and the
                 total size of the sections. If there is no segment or section
                 data, size prints an error message and stops processing.
    
    
           -o
                 Prints numbers in octal, not decimal.
    
    
           -V
                 Prints the version information for the size command on the
                 standard error output.
    
    
           -x
                 Prints numbers in hexadecimal, not decimal.
    
    
    EXAMPLES
           The examples below are typical size output.
    
           Example 1 Producing size information
    
             example% size filename
             2724 + 88 + 0 = 2812
    
    
    
           Example 2 Producing allocatable section size information
    
             example% size -f filename
             26(.text) + 5(.init) + 5(.fini) = 36
    
    
    
           Example 3 Producing loadable segment size information
    
             example% size -F filename
             2724(r-x) + 88(rwx) + 0(rwx) = 2812 ... (If statically linked)
    
    
    
    SEE ALSO
           as(1), ld(1), ar.h(3HEAD), a.out(4), attributes(5)
    
    NOTES
           Since the size of bss sections is not known until link-edit time, the
           size command will not give the true total size of pre-linked objects.
    
    
    
                                    August 24, 2009                        SIZE(1)
    

    关于输出的更多信息size可以在这里找到

    • 1

相关问题

  • 有没有办法让 ls 只显示某些目录的隐藏文件?

  • 使用键盘快捷键启动/停止 systemd 服务 [关闭]

  • 需要一些系统调用

  • astyle 不会更改源文件格式

  • 通过标签将根文件系统传递给linux内核

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何将 GPG 私钥和公钥导出到文件

    • 4 个回答
  • Marko Smith

    ssh 无法协商:“找不到匹配的密码”,正在拒绝 cbc

    • 4 个回答
  • Marko Smith

    我们如何运行存储在变量中的命令?

    • 5 个回答
  • Marko Smith

    如何配置 systemd-resolved 和 systemd-networkd 以使用本地 DNS 服务器来解析本地域和远程 DNS 服务器来解析远程域?

    • 3 个回答
  • Marko Smith

    如何卸载内核模块“nvidia-drm”?

    • 13 个回答
  • Marko Smith

    dist-upgrade 后 Kali Linux 中的 apt-get update 错误 [重复]

    • 2 个回答
  • Marko Smith

    如何从 systemctl 服务日志中查看最新的 x 行

    • 5 个回答
  • Marko Smith

    Nano - 跳转到文件末尾

    • 8 个回答
  • Marko Smith

    grub 错误:你需要先加载内核

    • 4 个回答
  • Marko Smith

    如何下载软件包而不是使用 apt-get 命令安装它?

    • 7 个回答
  • Martin Hope
    rocky 如何将 GPG 私钥和公钥导出到文件 2018-11-16 05:36:15 +0800 CST
  • Martin Hope
    Wong Jia Hau ssh-add 返回:“连接代理时出错:没有这样的文件或目录” 2018-08-24 23:28:13 +0800 CST
  • Martin Hope
    Evan Carroll systemctl 状态显示:“状态:降级” 2018-06-03 18:48:17 +0800 CST
  • Martin Hope
    Tim 我们如何运行存储在变量中的命令? 2018-05-21 04:46:29 +0800 CST
  • Martin Hope
    Ankur S 为什么 /dev/null 是一个文件?为什么它的功能不作为一个简单的程序来实现? 2018-04-17 07:28:04 +0800 CST
  • Martin Hope
    user3191334 如何从 systemctl 服务日志中查看最新的 x 行 2018-02-07 00:14:16 +0800 CST
  • Martin Hope
    Marko Pacak Nano - 跳转到文件末尾 2018-02-01 01:53:03 +0800 CST
  • Martin Hope
    Kidburla 为什么真假这么大? 2018-01-26 12:14:47 +0800 CST
  • Martin Hope
    Christos Baziotis 在一个巨大的(70GB)、一行、文本文件中替换字符串 2017-12-30 06:58:33 +0800 CST
  • Martin Hope
    Bagas Sanjaya 为什么 Linux 使用 LF 作为换行符? 2017-12-20 05:48:21 +0800 CST

热门标签

linux bash debian shell-script text-processing ubuntu centos shell awk ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve