LibELF: Don't try to call mremap() on macOS

There is no mremap() on macOS. I'm just #ifdef'ing out the call here
since I don't think the dynamic loader code matters on macOS anyway.
This commit is contained in:
Andreas Kling 2020-12-29 10:55:35 +01:00
parent d0363bca01
commit 5c99296b92
Notes: sideshowbarker 2024-07-19 00:27:50 +09:00

View file

@ -185,11 +185,13 @@ bool DynamicLoader::load_stage_2(unsigned flags, size_t total_tls_size)
// dbg() << "Someone linked non -fPIC code into " << m_filename << " :(";
ASSERT(m_text_segment_load_address.get() != 0);
#ifndef AK_OS_MACOS
// Remap this text region as private.
if (mremap(m_text_segment_load_address.as_ptr(), m_text_segment_size, m_text_segment_size, MAP_PRIVATE) == MAP_FAILED) {
perror("mremap .text: MAP_PRIVATE");
return false;
}
#endif
if (0 > mprotect(m_text_segment_load_address.as_ptr(), m_text_segment_size, PROT_READ | PROT_WRITE)) {
perror("mprotect .text: PROT_READ | PROT_WRITE"); // FIXME: dlerror?