我正在 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
答案1
size
尽管按照您的说明安装了命令行工具包,但您似乎已经安装了 GNU 。尝试:/Library/Developer/CommandLineTools/usr/bin/size
。
如果您的操作系统是 El Capitan (10.11) 或更高版本,则必须禁用啜(至少暂时)以便安装到 /bin、/sbin 和 /usr 等目录(但不是 /usr/local)。