[llvm] [llvm-size] Add -z option for Mach-O to exclude __PAGEZERO size. (PR #159574)

Daniel Rodríguez Troitiño via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 23 10:00:17 PDT 2025


drodriguez wrote:

If we use Xcode's `size` instead of `llvm-size`, I get the same display.

```
$ build/bin/yaml2obj llvm/test/tools/llvm-size/macho-pagezero.test --docnum=1 -o macho-pagezero.o
$ build/bin/llvm-size macho-pagezero.o
__TEXT	__DATA	__OBJC	others	dec	hex
20	100	0	4096	4216	1078
$ size macho-pagezero.o
__TEXT	__DATA	__OBJC	others	dec	hex
20	100	0	4096	4216	1078
```

The man page for `size` does not have a `-z` option (it has `-m`, `-l`, `-x` and `-arch`. Except `-arch`, the rest seems to be supported). Like @jh7370 says, maybe `-z` is not the best spelling for an option here, and a long one that makes clear is not for compatibility makes more sense.

But in the Xcode man page one can also find the following:

> Size (without the -m option) prints the (decimal) number of bytes required by the __TEXT, __DATA and __OBJC segments.  All other segments are totaled and that size is listed in the `others' column.

Which explains the "others" category including `__PAGEZERO`.

If we want to provide this special behaviour because of a feature request, it should be obvious that it is not a compatibility flag or similar.

https://github.com/llvm/llvm-project/pull/159574


More information about the llvm-commits mailing list