diff options
| author | 2024-12-19 17:56:02 +0000 | |
|---|---|---|
| committer | 2025-01-30 10:55:25 -0800 | |
| commit | 55cb961ae83563eed14fb3aecc7debafc9c86192 (patch) | |
| tree | 9c4ba4f5769cedc56873a6db63feee65ec0887e3 /compiler/optimizing/nodes_vector.h | |
| parent | f10036f351515b670e9480aebef009f35ced8bb6 (diff) | |
Reduce alignment for .rodata section in OAT files
This patch removes almost 16 KiB of padding at the start of each
OAT file, by reducing .rodata alignment from kElfSegmentAlignment
(16 KiB) to 4 bytes. It is valid to do because:
* The first loadable segment in the OAT (ELF) file is specified to
start at 0x0 and includes the .rodata and data before it (ELF
header, program headers, etc.):
+--------+---------+--------------------+---------+
| ELF | program | optional | .rodata |
| header | headers | .note.gnu.build-id | |
+--------+---------+--------------------+---------+
^ ^
| |
+-------- first loadable segment in memory -------+
|
+-- page-aligned
This patch does not change the alignment of this first loadable
segment mapped by the linker (both bionic's linker and ART's one),
it only reduces the size of the mapping by reducing the padding
within it.
* Content of .rodata doesn't need to be page-aligned, the maximum
memory alignment that it requires is 4 bytes.
At the moment the OatWriter uses offsets relative to the oat header
(actually the start of the .rodata); so all data *in other sections*
that requires more than 4-byte memory-alignment must account for
the fact that the header is no longer kElfSegmentAlignment aligned
and instead use the offset from the start of the file.
This patch also fixes an issue with the algorithm in
ImmuneSpaces::CreateLargestImmuneRegion, specifically when ART's
ELF loader is used. As this loader only guarantees mmaps begin on a
page-size aligned virtual address (rather than aligning to the largest
segment alignment as done via dlopen implementations), it is possible
that when an image space's end is rounded up to 16K, it may overlap
the next space's begin (see an illustration below), causing a failure.
Therefore, instead round up the end to the next 4K boundary when
calculating the region.
image space interval
/---------------------------+ oat space interval
\ +------+----------------------------/
/ | | \
\---+----------+-----+------+----------------------------/
/ | | | | \
\---+----------+-----+------+----------------------------/
^ ^ ^ ^
| | | +----- image space end (16 KiB aligned)
image end | |
| +-- oatdata (.rodata)
|
oat file (4 KiB aligned)
Actual disk usage reduction from this patch:
* Approx 90% of tested dense .odex files are reduced by 16 KiB
(all reductions are in range 0-16 KiB).
* Approx 75% of tested sparse .odex files are reduced by 4 KiB
(all reductions are in range 0-4 KiB).
Authors: Richard Neill <richard.neill@arm.com>
Konstantin Baladurin <konstantin.baladurin@arm.com>
Test: testrunner.py --optimizing
Bug: 378792349
Change-Id: I874bad5bea28fa1bcf66f331e7d74a506dda72cc
Diffstat (limited to 'compiler/optimizing/nodes_vector.h')
0 files changed, 0 insertions, 0 deletions