Linker: clear error for incorrect page size load.
When the alignment of an ELF program is smaller than page size,
the program is malformed, and the linker will crash with an unclear
error:
dlopen failed: empty/missing DT_HASH/DT_GNU_HASH
Now, we explicitly check the alignment, only on >= 16KB page size
machines, so we get a clearer error:
Test: e.g.:
dlopen failed: "/data/local/tmp/bionic-unit-tests/x86_64/bionic-loader-test-libs/prebuilt-elf-files/libtest_invalid-rw_load_segment.so" program alignment (4096) cannot be smaller than system page size (16384)
Bug: 342480592
Change-Id: I2fa50c0d8cca34acde03d71d8dc600dc3858ca04
diff --git a/linker/linker_phdr.h b/linker/linker_phdr.h
index aab9018..e865a03 100644
--- a/linker/linker_phdr.h
+++ b/linker/linker_phdr.h
@@ -126,6 +126,7 @@
ElfW(Addr)* min_vaddr = nullptr, ElfW(Addr)* max_vaddr = nullptr);
size_t phdr_table_get_maximum_alignment(const ElfW(Phdr)* phdr_table, size_t phdr_count);
+size_t phdr_table_get_minimum_alignment(const ElfW(Phdr)* phdr_table, size_t phdr_count);
int phdr_table_protect_segments(const ElfW(Phdr)* phdr_table, size_t phdr_count,
ElfW(Addr) load_bias, bool should_pad_segments,