我正在研究 macOS 并在 cc 上尝试了 size 命令
$ which cc
/usr/bin/cc
它不能正常工作
$ size /usr/bin/cc
size: /usr/bin/cc: unknown load command 0x32
size: /usr/bin/cc: unknown load command 0x32
size: /usr/bin/cc: unknown load command 0x32
size: /usr/bin/cc: file format not recognized
$ size /bin/ls
size: /bin/ls: unknown load command 0x32
size: /bin/ls: unknown load command 0x32
size: /bin/ls: unknown load command 0x32
size: /bin/ls: file format not recognized
并且尺寸是最新版本
$ size --version
GNU size (GNU Binutils) 2.31.1
Copyright (C) 2018 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.
但是在 Centos 上
[root@iz2ze9wve43n2nyuvmsfx5z ~]# size /usr/bin/cc
text data bss dec hex filename
754853 8488 81856 845197 ce58d /usr/bin/cc
命令大小有什么问题?
$ file /usr/bin/cc
/usr/bin/cc: Mach-O 64-bit executable x86_64
$ size --help
Usage: size [option(s)] [file(s)]
Displays the sizes of sections inside binary files
If no input file(s) are specified, a.out is assumed
The options are:
-A|-B --format={sysv|berkeley} Select output style (default is berkeley)
-o|-d|-x --radix={8|10|16} Display numbers in octal, decimal or hex
-t --totals Display the total sizes (Berkeley only)
--common Display total size for *COM* syms
--target=<bfdname> Set the binary file format
@<file> Read options from <file>
-h --help Display this information
-v --version Display the program's version
这行得通
me at Max-2018 in ~/desktop
$ /Library/Developer/CommandLineTools/usr/bin/size /usr/bin/cc
__TEXT __DATA __OBJC others dec hex
4096 4096 0 4294979584 4294987776 100005000
$ ls /Library/Developer/CommandLineTools/usr/bin | grep size
llvm-size
size
size-classic
size
尽管按照您的说明安装了命令行工具包,但您似乎已经安装了 GNU 。试试:/Library/Developer/CommandLineTools/usr/bin/size
。如果您的操作系统是 El Capitan (10.11) 或更高版本,您必须禁用SIP(至少暂时)才能安装到 /bin、/sbin 和 /usr 等目录(但不是 /usr/local)。