Skip to content

Commit ed93efb

Browse files
committed
Add entry in the command guide for --exclude-pagezero option.
Add test for 32 bit __PAGEZERO segment.
1 parent 7e7b187 commit ed93efb

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

llvm/docs/CommandGuide/llvm-size.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ OPTIONS
4141
as a separate section entry for ``sysv`` output. If not specified, these
4242
symbols are ignored.
4343

44+
.. option:: --exclude-pagezero
45+
46+
Do not include the ``__PAGEZERO`` segment when calculating size information
47+
for Mach-O files. ``__PAGEZERO`` segment is a virtual memory region used
48+
for memory protection that does not contribute to actual size, and excluding
49+
can provide a better representation of actual size.
50+
4451
.. option:: -d
4552

4653
Equivalent to :option:`--radix` with a value of ``10``.

llvm/test/tools/llvm-size/macho-pagezero.test

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,24 @@
66
# RUN: llvm-size --exclude-pagezero %t-pagezero.o | \
77
# RUN: FileCheck %s --check-prefix=SKIP --match-full-lines
88

9+
# RUN: yaml2obj %s --docnum=2 -o %t-pagezero32.o
10+
# RUN: llvm-size %t-pagezero32.o | \
11+
# RUN: FileCheck %s --check-prefix=NORMAL32 --match-full-lines
12+
# RUN: llvm-size --exclude-pagezero %t-pagezero32.o | \
13+
# RUN: FileCheck %s --check-prefix=SKIP32 --match-full-lines
14+
915
# NORMAL:__TEXT __DATA __OBJC others dec hex
1016
# NORMAL-NEXT:20 100 0 4096 4216 1078
1117

1218
# SKIP:__TEXT __DATA __OBJC others dec hex
1319
# SKIP-NEXT:20 100 0 0 120 78
1420

21+
# NORMAL32:__TEXT __DATA __OBJC others dec hex
22+
# NORMAL32-NEXT:20 100 0 4096 4216 1078
23+
24+
# SKIP32:__TEXT __DATA __OBJC others dec hex
25+
# SKIP32-NEXT:20 100 0 0 120 78
26+
1527
--- !mach-o
1628
FileHeader:
1729
magic: 0xFEEDFACF
@@ -56,3 +68,47 @@ LoadCommands:
5668
initprot: 3
5769
nsects: 0
5870
flags: 0
71+
72+
--- !mach-o
73+
FileHeader:
74+
magic: 0xFEEDFACE
75+
cputype: 0x7
76+
cpusubtype: 0x3
77+
filetype: 0x2
78+
ncmds: 3
79+
sizeofcmds: 168
80+
flags: 0x2000
81+
LoadCommands:
82+
- cmd: LC_SEGMENT
83+
cmdsize: 56
84+
segname: __PAGEZERO
85+
vmaddr: 0x0
86+
vmsize: 4096
87+
fileoff: 0
88+
filesize: 0
89+
maxprot: 0
90+
initprot: 0
91+
nsects: 0
92+
flags: 0
93+
- cmd: LC_SEGMENT
94+
cmdsize: 56
95+
segname: __TEXT
96+
vmaddr: 0x1000
97+
vmsize: 20
98+
fileoff: 196
99+
filesize: 20
100+
maxprot: 7
101+
initprot: 5
102+
nsects: 0
103+
flags: 0
104+
- cmd: LC_SEGMENT
105+
cmdsize: 56
106+
segname: __DATA
107+
vmaddr: 0x2000
108+
vmsize: 100
109+
fileoff: 216
110+
filesize: 100
111+
maxprot: 7
112+
initprot: 3
113+
nsects: 0
114+
flags: 0

0 commit comments

Comments
 (0)