DynamicLoader.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. /*
  2. * Copyright (c) 2019-2020, Andrew Kaster <andrewdkaster@gmail.com>
  3. * Copyright (c) 2020, Itamar S. <itamar8910@gmail.com>
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright notice, this
  10. * list of conditions and the following disclaimer.
  11. *
  12. * 2. Redistributions in binary form must reproduce the above copyright notice,
  13. * this list of conditions and the following disclaimer in the documentation
  14. * and/or other materials provided with the distribution.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  17. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  18. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  20. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  21. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  22. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  23. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  24. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  25. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. #include <AK/StringBuilder.h>
  28. #include <LibELF/DynamicLoader.h>
  29. #include <LibELF/Validation.h>
  30. #include <assert.h>
  31. #include <dlfcn.h>
  32. #include <stdio.h>
  33. #include <stdlib.h>
  34. #include <string.h>
  35. #include <sys/mman.h>
  36. #ifndef DYNAMIC_LOAD_DEBUG
  37. # define DYNAMIC_LOAD_DEBUG
  38. #endif
  39. // #define DYNAMIC_LOAD_VERBOSE
  40. #ifdef DYNAMIC_LOAD_VERBOSE
  41. # define VERBOSE(fmt, ...) dbgprintf(fmt, ##__VA_ARGS__)
  42. #else
  43. # define VERBOSE(fmt, ...) \
  44. do { \
  45. } while (0)
  46. #endif
  47. #ifndef __serenity__
  48. static void* mmap_with_name(void* addr, size_t length, int prot, int flags, int fd, off_t offset, const char*)
  49. {
  50. return mmap(addr, length, prot, flags, fd, offset);
  51. }
  52. #endif
  53. namespace ELF {
  54. static bool s_always_bind_now = false;
  55. NonnullRefPtr<DynamicLoader> DynamicLoader::construct(const char* filename, int fd, size_t size)
  56. {
  57. return adopt(*new DynamicLoader(filename, fd, size));
  58. }
  59. void* DynamicLoader::do_mmap(int fd, size_t size, const String& name)
  60. {
  61. if (size < sizeof(Elf32_Ehdr))
  62. return MAP_FAILED;
  63. String file_mmap_name = String::format("ELF_DYN: %s", name.characters());
  64. return mmap_with_name(nullptr, size, PROT_READ, MAP_PRIVATE, fd, 0, file_mmap_name.characters());
  65. }
  66. DynamicLoader::DynamicLoader(const char* filename, int fd, size_t size)
  67. : m_filename(filename)
  68. , m_file_size(size)
  69. , m_image_fd(fd)
  70. , m_file_mapping(do_mmap(m_image_fd, m_file_size, m_filename))
  71. , m_elf_image((u8*)m_file_mapping, m_file_size)
  72. {
  73. if (m_file_mapping == MAP_FAILED) {
  74. m_valid = false;
  75. return;
  76. }
  77. m_tls_size = calculate_tls_size();
  78. m_valid = validate();
  79. }
  80. RefPtr<DynamicObject> DynamicLoader::dynamic_object_from_image() const
  81. {
  82. VirtualAddress dynamic_section_address;
  83. m_elf_image.for_each_program_header([&dynamic_section_address](auto program_header) {
  84. if (program_header.type() == PT_DYNAMIC) {
  85. dynamic_section_address = VirtualAddress(program_header.raw_data());
  86. }
  87. return IterationDecision::Continue;
  88. });
  89. ASSERT(!dynamic_section_address.is_null());
  90. return ELF::DynamicObject::construct(VirtualAddress(m_elf_image.base_address()), dynamic_section_address);
  91. }
  92. size_t DynamicLoader::calculate_tls_size() const
  93. {
  94. size_t tls_size = 0;
  95. m_elf_image.for_each_program_header([&tls_size](auto program_header) {
  96. if (program_header.type() == PT_TLS) {
  97. tls_size = program_header.size_in_memory();
  98. }
  99. return IterationDecision::Continue;
  100. });
  101. return tls_size;
  102. }
  103. bool DynamicLoader::validate()
  104. {
  105. auto* elf_header = (Elf32_Ehdr*)m_file_mapping;
  106. return validate_elf_header(*elf_header, m_file_size) && validate_program_headers(*elf_header, m_file_size, (u8*)m_file_mapping, m_file_size, &m_program_interpreter);
  107. }
  108. DynamicLoader::~DynamicLoader()
  109. {
  110. if (MAP_FAILED != m_file_mapping)
  111. munmap(m_file_mapping, m_file_size);
  112. close(m_image_fd);
  113. }
  114. void* DynamicLoader::symbol_for_name(const char* name)
  115. {
  116. auto symbol = m_dynamic_object->hash_section().lookup_symbol(name);
  117. if (symbol.is_undefined())
  118. return nullptr;
  119. return m_dynamic_object->base_address().offset(symbol.value()).as_ptr();
  120. }
  121. RefPtr<DynamicObject> DynamicLoader::load_from_image(unsigned flags, size_t total_tls_size)
  122. {
  123. m_valid = m_elf_image.is_valid();
  124. if (!m_valid) {
  125. dbgprintf("DynamicLoader::load_from_image failed: image is invalid\n");
  126. return nullptr;
  127. }
  128. #ifdef DYNAMIC_LOAD_VERBOSE
  129. // m_image->dump();
  130. #endif
  131. load_program_headers();
  132. m_dynamic_object = DynamicObject::construct(m_text_segment_load_address, m_dynamic_section_address);
  133. m_dynamic_object->set_tls_offset(m_tls_offset);
  134. m_dynamic_object->set_tls_size(m_tls_size);
  135. ASSERT(m_global_symbol_lookup_func);
  136. m_dynamic_object->m_global_symbol_lookup_func = m_global_symbol_lookup_func;
  137. auto rc = load_stage_2(flags, total_tls_size);
  138. if (!rc) {
  139. dbgprintf("DynamicLoader::load_from_image failed at load_stage_2\n");
  140. return nullptr;
  141. }
  142. return m_dynamic_object;
  143. }
  144. bool DynamicLoader::load_stage_2(unsigned flags, size_t total_tls_size)
  145. {
  146. ASSERT(flags & RTLD_GLOBAL);
  147. #ifdef DYNAMIC_LOAD_DEBUG
  148. m_dynamic_object->dump();
  149. #endif
  150. if (m_dynamic_object->has_text_relocations()) {
  151. // dbg() << "Someone linked non -fPIC code into " << m_filename << " :(";
  152. ASSERT(m_text_segment_load_address.get() != 0);
  153. if (0 > mprotect(m_text_segment_load_address.as_ptr(), m_text_segment_size, PROT_READ | PROT_WRITE)) {
  154. perror("mprotect .text: PROT_READ | PROT_WRITE"); // FIXME: dlerror?
  155. return false;
  156. }
  157. }
  158. do_relocations(total_tls_size);
  159. if (flags & RTLD_LAZY) {
  160. setup_plt_trampoline();
  161. }
  162. // Clean up our setting of .text to PROT_READ | PROT_WRITE
  163. if (m_dynamic_object->has_text_relocations()) {
  164. if (0 > mprotect(m_text_segment_load_address.as_ptr(), m_text_segment_size, PROT_READ | PROT_EXEC)) {
  165. perror("mprotect .text: PROT_READ | PROT_EXEC"); // FIXME: dlerror?
  166. return false;
  167. }
  168. }
  169. call_object_init_functions();
  170. VERBOSE("Loaded %s\n", m_filename.characters());
  171. return true;
  172. }
  173. void DynamicLoader::load_program_headers()
  174. {
  175. Vector<ProgramHeaderRegion> program_headers;
  176. ProgramHeaderRegion* text_region_ptr = nullptr;
  177. ProgramHeaderRegion* data_region_ptr = nullptr;
  178. ProgramHeaderRegion* tls_region_ptr = nullptr;
  179. VirtualAddress dynamic_region_desired_vaddr;
  180. m_elf_image.for_each_program_header([&](const Image::ProgramHeader& program_header) {
  181. ProgramHeaderRegion new_region;
  182. new_region.set_program_header(program_header.raw_header());
  183. program_headers.append(move(new_region));
  184. auto& region = program_headers.last();
  185. if (region.is_tls_template())
  186. tls_region_ptr = &region;
  187. else if (region.is_load()) {
  188. if (region.is_executable())
  189. text_region_ptr = &region;
  190. else
  191. data_region_ptr = &region;
  192. } else if (region.is_dynamic()) {
  193. dynamic_region_desired_vaddr = region.desired_load_address();
  194. }
  195. return IterationDecision::Continue;
  196. });
  197. ASSERT(text_region_ptr && data_region_ptr);
  198. // Process regions in order: .text, .data, .tls
  199. auto* region = text_region_ptr;
  200. void* requested_load_address = m_elf_image.is_dynamic() ? nullptr : region->desired_load_address().as_ptr();
  201. void* text_segment_begin = mmap_with_name(
  202. requested_load_address,
  203. region->required_load_size(),
  204. region->mmap_prot(),
  205. MAP_PRIVATE,
  206. m_image_fd,
  207. region->offset(),
  208. String::format("%s: .text", m_filename.characters()).characters());
  209. if (MAP_FAILED == text_segment_begin) {
  210. ASSERT_NOT_REACHED();
  211. }
  212. ASSERT(requested_load_address == nullptr || requested_load_address == text_segment_begin);
  213. m_text_segment_size = region->required_load_size();
  214. m_text_segment_load_address = VirtualAddress { (FlatPtr)text_segment_begin };
  215. if (m_elf_image.is_dynamic())
  216. m_dynamic_section_address = dynamic_region_desired_vaddr.offset(m_text_segment_load_address.get());
  217. else
  218. m_dynamic_section_address = dynamic_region_desired_vaddr;
  219. region = data_region_ptr;
  220. void* data_segment_begin = mmap_with_name(
  221. (u8*)text_segment_begin + m_text_segment_size,
  222. region->required_load_size(),
  223. region->mmap_prot(),
  224. MAP_ANONYMOUS | MAP_PRIVATE,
  225. 0,
  226. 0,
  227. String::format("%s: .data", m_filename.characters()).characters());
  228. if (MAP_FAILED == data_segment_begin) {
  229. ASSERT_NOT_REACHED();
  230. }
  231. VirtualAddress data_segment_actual_addr;
  232. if (m_elf_image.is_dynamic()) {
  233. data_segment_actual_addr = region->desired_load_address().offset((FlatPtr)text_segment_begin);
  234. } else {
  235. data_segment_actual_addr = region->desired_load_address();
  236. }
  237. memcpy(data_segment_actual_addr.as_ptr(), (u8*)m_file_mapping + region->offset(), region->size_in_image());
  238. // FIXME: Initialize the values in the TLS section. Currently, it is zeroed.
  239. }
  240. void DynamicLoader::do_relocations(size_t total_tls_size)
  241. {
  242. auto main_relocation_section = m_dynamic_object->relocation_section();
  243. main_relocation_section.for_each_relocation([&](ELF::DynamicObject::Relocation relocation) {
  244. VERBOSE("Relocation symbol: %s, type: %d\n", relocation.symbol().name(), relocation.type());
  245. FlatPtr* patch_ptr = nullptr;
  246. if (is_dynamic())
  247. patch_ptr = (FlatPtr*)(m_dynamic_object->base_address().as_ptr() + relocation.offset());
  248. else
  249. patch_ptr = (FlatPtr*)(FlatPtr)relocation.offset();
  250. // VERBOSE("dynamic object name: %s\n", dynamic_object.object_name());
  251. VERBOSE("dynamic object base address: %p\n", m_dynamic_object->base_address());
  252. VERBOSE("relocation offset: 0x%x\n", relocation.offset());
  253. VERBOSE("patch_ptr: %p\n", patch_ptr);
  254. switch (relocation.type()) {
  255. case R_386_NONE:
  256. // Apparently most loaders will just skip these?
  257. // Seems if the 'link editor' generates one something is funky with your code
  258. VERBOSE("None relocation. No symbol, no nothin.\n");
  259. break;
  260. case R_386_32: {
  261. auto symbol = relocation.symbol();
  262. VERBOSE("Absolute relocation: name: '%s', value: %p\n", symbol.name(), symbol.value());
  263. auto res = lookup_symbol(symbol);
  264. if (!res.found) {
  265. dbgln("ERROR: symbol not found: {}", symbol.name());
  266. ASSERT_NOT_REACHED();
  267. }
  268. u32 symbol_address = res.address;
  269. *patch_ptr += symbol_address;
  270. VERBOSE(" Symbol address: %p\n", *patch_ptr);
  271. break;
  272. }
  273. case R_386_PC32: {
  274. auto symbol = relocation.symbol();
  275. VERBOSE("PC-relative relocation: '%s', value: %p\n", symbol.name(), symbol.value());
  276. auto res = lookup_symbol(symbol);
  277. ASSERT(res.found);
  278. u32 relative_offset = (res.address - (FlatPtr)(m_dynamic_object->base_address().as_ptr() + relocation.offset()));
  279. *patch_ptr += relative_offset;
  280. VERBOSE(" Symbol address: %p\n", *patch_ptr);
  281. break;
  282. }
  283. case R_386_GLOB_DAT: {
  284. auto symbol = relocation.symbol();
  285. VERBOSE("Global data relocation: '%s', value: %p\n", symbol.name(), symbol.value());
  286. auto res = lookup_symbol(symbol);
  287. if (!res.found) {
  288. // We do not support these
  289. // TODO: Can we tell gcc not to generate the piece of code that uses these?
  290. // (--disable-tm-clone-registry flag in gcc conifugraion?)
  291. if (!strcmp(symbol.name(), "__deregister_frame_info") || !strcmp(symbol.name(), "_ITM_registerTMCloneTable")
  292. || !strcmp(symbol.name(), "_ITM_deregisterTMCloneTable") || !strcmp(symbol.name(), "__register_frame_info")) {
  293. break;
  294. }
  295. // The "__do_global_dtors_aux" function in libgcc_s.so needs this symbol,
  296. // but we do not use that function so we don't actually need to resolve this symbol.
  297. // The reason we can't resolve it here is that the symbol is defined in libc.so,
  298. // but there's a circular dependecy between libgcc_s.so and libc.so,
  299. // we deal with it by first loading libgcc_s and then libc.
  300. // So we cannot find this symbol at this time (libc is not yet loaded).
  301. if (m_filename == "libgcc_s.so" && !strcmp(symbol.name(), "__cxa_finalize")) {
  302. break;
  303. }
  304. // Symbol not found
  305. ASSERT_NOT_REACHED();
  306. }
  307. VERBOSE("was symbol found? %d, address: 0x%x\n", res.found, res.address);
  308. VERBOSE("object: %s\n", m_filename.characters());
  309. if (!res.found) {
  310. // TODO this is a hack
  311. ASSERT(!strcmp(symbol.name(), "__deregister_frame_info") || !strcmp(symbol.name(), "_ITM_registerTMCloneTable")
  312. || !strcmp(symbol.name(), "_ITM_deregisterTMCloneTable") || !strcmp(symbol.name(), "__register_frame_info"));
  313. ASSERT_NOT_REACHED();
  314. return IterationDecision::Continue;
  315. }
  316. // ASSERT(res.found);
  317. u32 symbol_location = res.address;
  318. ASSERT(symbol_location != (FlatPtr)m_dynamic_object->base_address().as_ptr());
  319. *patch_ptr = symbol_location;
  320. VERBOSE(" Symbol address: %p\n", *patch_ptr);
  321. break;
  322. }
  323. case R_386_RELATIVE: {
  324. // FIXME: According to the spec, R_386_relative ones must be done first.
  325. // We could explicitly do them first using m_number_of_relocatoins from DT_RELCOUNT
  326. // However, our compiler is nice enough to put them at the front of the relocations for us :)
  327. VERBOSE("Load address relocation at offset %X\n", relocation.offset());
  328. VERBOSE(" patch ptr == %p, adding load base address (%p) to it and storing %p\n", *patch_ptr, m_dynamic_object->base_address().as_ptr(), *patch_ptr + m_dynamic_object->base_address().as_ptr());
  329. *patch_ptr += (FlatPtr)m_dynamic_object->base_address().as_ptr(); // + addend for RelA (addend for Rel is stored at addr)
  330. break;
  331. }
  332. case R_386_TLS_TPOFF32:
  333. case R_386_TLS_TPOFF: {
  334. VERBOSE("Relocation type: R_386_TLS_TPOFF at offset %X\n", relocation.offset());
  335. auto symbol = relocation.symbol();
  336. // For some reason, LibC has a R_386_TLS_TPOFF that referes to the undefined symbol.. huh
  337. if (relocation.symbol_index() == 0)
  338. break;
  339. VERBOSE("Symbol index: %d\n", symbol.index());
  340. VERBOSE("Symbol is_undefined?: %d\n", symbol.is_undefined());
  341. VERBOSE("TLS relocation: '%s', value: %p\n", symbol.name(), symbol.value());
  342. auto res = lookup_symbol(symbol);
  343. if (!res.found)
  344. break;
  345. ASSERT(res.found);
  346. u32 symbol_value = res.value;
  347. VERBOSE("symbol value: %d\n", symbol_value);
  348. const auto dynamic_object_of_symbol = res.dynamic_object;
  349. ASSERT(dynamic_object_of_symbol);
  350. size_t offset_of_tls_end = dynamic_object_of_symbol->tls_offset().value() + dynamic_object_of_symbol->tls_size().value();
  351. // size_t offset_of_tls_end = tls_offset() + tls_size();
  352. VERBOSE("patch ptr: 0x%x\n", patch_ptr);
  353. VERBOSE("tls end offset: %d, total tls size: %d\n", offset_of_tls_end, total_tls_size);
  354. *patch_ptr = (offset_of_tls_end - total_tls_size - symbol_value - sizeof(Elf32_Addr));
  355. VERBOSE("*patch ptr: %d\n", (i32)*patch_ptr);
  356. break;
  357. }
  358. default:
  359. // Raise the alarm! Someone needs to implement this relocation type
  360. VERBOSE("Found a new exciting relocation type %d\n", relocation.type());
  361. // printf("DynamicLoader: Found unknown relocation type %d\n", relocation.type());
  362. ASSERT_NOT_REACHED();
  363. break;
  364. }
  365. return IterationDecision::Continue;
  366. });
  367. VERBOSE("plt relocations: 0x%x", m_dynamic_object->plt_relocation_section().address());
  368. VERBOSE("plt relocation count: 0x%x", m_dynamic_object->plt_relocation_section().address());
  369. VERBOSE("plt size: %d\n", m_dynamic_object->plt_relocation_section().size());
  370. VERBOSE("plt entry size: 0x%x\n", m_dynamic_object->plt_relocation_section().entry_size());
  371. // Handle PLT Global offset table relocations.
  372. m_dynamic_object->plt_relocation_section().for_each_relocation([&](const DynamicObject::Relocation& relocation) {
  373. // FIXME: Or BIND_NOW flag passed in?
  374. if (m_dynamic_object->must_bind_now() || s_always_bind_now) {
  375. // Eagerly BIND_NOW the PLT entries, doing all the symbol looking goodness
  376. // The patch method returns the address for the LAZY fixup path, but we don't need it here
  377. VERBOSE("patching plt reloaction: 0x%x\n", relocation.offset_in_section());
  378. [[maybe_unused]] auto rc = m_dynamic_object->patch_plt_entry(relocation.offset_in_section());
  379. } else {
  380. ASSERT(relocation.type() == R_386_JMP_SLOT);
  381. u8* relocation_address = relocation.address().as_ptr();
  382. if (m_elf_image.is_dynamic())
  383. *(u32*)relocation_address += (FlatPtr)m_dynamic_object->base_address().as_ptr();
  384. }
  385. return IterationDecision::Continue;
  386. });
  387. VERBOSE("Done relocating!\n");
  388. }
  389. // Defined in <arch>/plt_trampoline.S
  390. extern "C" void _plt_trampoline(void) __attribute__((visibility("hidden")));
  391. void DynamicLoader::setup_plt_trampoline()
  392. {
  393. ASSERT(m_dynamic_object);
  394. VirtualAddress got_address = m_dynamic_object->plt_got_base_address();
  395. FlatPtr* got_ptr = (FlatPtr*)got_address.as_ptr();
  396. got_ptr[1] = (FlatPtr)m_dynamic_object.ptr();
  397. got_ptr[2] = (FlatPtr)&_plt_trampoline;
  398. VERBOSE("Set GOT PLT entries at %p: [0] = %p [1] = %p, [2] = %p\n", got_ptr, (void*)got_ptr[0], (void*)got_ptr[1], (void*)got_ptr[2]);
  399. }
  400. // Called from our ASM routine _plt_trampoline.
  401. // Tell the compiler that it might be called from other places:
  402. extern "C" Elf32_Addr _fixup_plt_entry(DynamicObject* object, u32 relocation_offset);
  403. extern "C" Elf32_Addr _fixup_plt_entry(DynamicObject* object, u32 relocation_offset)
  404. {
  405. return object->patch_plt_entry(relocation_offset);
  406. }
  407. void DynamicLoader::call_object_init_functions()
  408. {
  409. typedef void (*InitFunc)();
  410. if (m_dynamic_object->has_init_section()) {
  411. auto init_function = (InitFunc)(m_dynamic_object->init_section().address().as_ptr());
  412. VERBOSE("Calling DT_INIT at %p\n", init_function);
  413. (init_function)();
  414. }
  415. if (m_dynamic_object->has_init_array_section()) {
  416. auto init_array_section = m_dynamic_object->init_array_section();
  417. InitFunc* init_begin = (InitFunc*)(init_array_section.address().as_ptr());
  418. InitFunc* init_end = init_begin + init_array_section.entry_count();
  419. while (init_begin != init_end) {
  420. // Android sources claim that these can be -1, to be ignored.
  421. // 0 definitely shows up. Apparently 0/-1 are valid? Confusing.
  422. if (!*init_begin || ((FlatPtr)*init_begin == (FlatPtr)-1))
  423. continue;
  424. VERBOSE("Calling DT_INITARRAY entry at %p\n", *init_begin);
  425. (*init_begin)();
  426. ++init_begin;
  427. }
  428. }
  429. }
  430. u32 DynamicLoader::ProgramHeaderRegion::mmap_prot() const
  431. {
  432. int prot = 0;
  433. prot |= is_executable() ? PROT_EXEC : 0;
  434. prot |= is_readable() ? PROT_READ : 0;
  435. prot |= is_writable() ? PROT_WRITE : 0;
  436. return prot;
  437. }
  438. DynamicObject::SymbolLookupResult DynamicLoader::lookup_symbol(const ELF::DynamicObject::Symbol& symbol) const
  439. {
  440. return m_dynamic_object->lookup_symbol(symbol);
  441. }
  442. } // end namespace ELF