Reapply "RELAND: bionic: loader: Extend LOAD segment VMAs"
This reverts commit 7a04fedc78a1355ffad5cedbe7b0195236d26a46.
Test: Dexcom G7 app
Bug: 328797737
Change-Id: I575d626b1313d1c66bf25f29c43a9a101024a4f8
Signed-off-by: Kalesh Singh <kaleshsingh@google.com>
diff --git a/linker/linker_main.cpp b/linker/linker_main.cpp
index d6592af..1860ccc 100644
--- a/linker/linker_main.cpp
+++ b/linker/linker_main.cpp
@@ -201,6 +201,7 @@
const ElfW(Phdr)* phdr;
size_t phdr_count;
ElfW(Addr) entry_point;
+ bool should_pad_segments;
};
static ExecutableInfo get_executable_info(const char* arg_path) {
@@ -293,6 +294,7 @@
result.phdr = elf_reader.loaded_phdr();
result.phdr_count = elf_reader.phdr_count();
result.entry_point = elf_reader.entry_point();
+ result.should_pad_segments = elf_reader.should_pad_segments();
return result;
}
@@ -366,6 +368,7 @@
somain = si;
si->phdr = exe_info.phdr;
si->phnum = exe_info.phdr_count;
+ si->set_should_pad_segments(exe_info.should_pad_segments);
get_elf_base_from_phdr(si->phdr, si->phnum, &si->base, &si->load_bias);
si->size = phdr_table_get_load_size(si->phdr, si->phnum);
si->dynamic = nullptr;
@@ -399,7 +402,7 @@
auto note_gnu_property = GnuPropertySection(somain);
if (note_gnu_property.IsBTICompatible() &&
(phdr_table_protect_segments(somain->phdr, somain->phnum, somain->load_bias,
- ¬e_gnu_property) < 0)) {
+ somain->should_pad_segments(), ¬e_gnu_property) < 0)) {
__linker_error("error: can't protect segments for \"%s\": %s", exe_info.path.c_str(),
strerror(errno));
}