diff options
author | 2025-01-10 14:07:53 +0000 | |
---|---|---|
committer | 2025-01-30 10:55:25 -0800 | |
commit | 7e3cf2bac4db55a735a3f35b2e6e0e7b4b49210e (patch) | |
tree | 9d41619560190b5f8bde4ff9f8b57f43b0b5cf61 /compiler/optimizing/stack_map_stream.h | |
parent | 55cb961ae83563eed14fb3aecc7debafc9c86192 (diff) |
Move dynamic sections to start of OAT file.
Extra padding is required in OAT files when a section have different
runtime permissions from the previous one, because in this case
it should be mmaped separately as a part of a new loadable segment
and therefore it should be page-aligned in the file.
This patch places read-only dynamic sections prior to the read-only
.rodata section (before it), thus combining a few R sections into
a segment and reducing the amount of padding required.
To do this:
* Change runtime permissions of .dynamic section from read-write to
read-only. This is valid because:
* Dynamic linker can update only DT_DEBUG entry that we don't use
* ELF spec does not require it to be writable. Rather, it states
that it can be writable depending on the OS and processor.
However, glibc versions < 2.35 have a bug that causes a crash
when loading a dynamic shared object with read-only .dynamic section
on host: (https://sourceware.org/bugzilla/show_bug.cgi?id=28340).
Therefore only use glibc's dlopen when it is version >= 2.35,
otherwise use ART's ELF loader. Bionic dlopen correctly accepts
read-only .dynamic section.
* Put the dynamic sections (.dynstr, .dynsym, .hash, .dynamic) prior
to the .rodata section. As content of dynamic sections depend on
other sections, we firstly reserve enough space for them before
.rodata and then generate actual data and write it.
Actual disk usage reduction from this patch:
* Approx 90% of tested dense .odex files are reduced by 40 KiB
(all reductions are in range 16-48 KiB).
* Approx 95% of tested sparse .odex files are reduced by 8 KiB
(all reductions are in range 4-16 Kib).
This patch, along with the patch that reduces .rodata alignment,
decreases the total sparse size of oat files from system.img
built for aosp_shiba-trunk_staging-user lunch target by 1.4%
(from ~222 MiB to ~219 MiB).
Test: testrunner.py --optimizing
Bug: 378792349
Change-Id: I2a4929adfdf8a496832880f42293371ae2e0e06b
Diffstat (limited to 'compiler/optimizing/stack_map_stream.h')
0 files changed, 0 insertions, 0 deletions