DynamicLoader.cpp 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  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. });
  88. ASSERT(!dynamic_section_address.is_null());
  89. return ELF::DynamicObject::construct(VirtualAddress(m_elf_image.base_address()), dynamic_section_address);
  90. }
  91. size_t DynamicLoader::calculate_tls_size() const
  92. {
  93. size_t tls_size = 0;
  94. m_elf_image.for_each_program_header([&tls_size](auto program_header) {
  95. if (program_header.type() == PT_TLS) {
  96. tls_size = program_header.size_in_memory();
  97. }
  98. });
  99. return tls_size;
  100. }
  101. bool DynamicLoader::validate()
  102. {
  103. auto* elf_header = (Elf32_Ehdr*)m_file_mapping;
  104. 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);
  105. }
  106. DynamicLoader::~DynamicLoader()
  107. {
  108. if (MAP_FAILED != m_file_mapping)
  109. munmap(m_file_mapping, m_file_size);
  110. close(m_image_fd);
  111. }
  112. void* DynamicLoader::symbol_for_name(const char* name)
  113. {
  114. auto symbol = m_dynamic_object->hash_section().lookup_symbol(name);
  115. if (symbol.is_undefined())
  116. return nullptr;
  117. return m_dynamic_object->base_address().offset(symbol.value()).as_ptr();
  118. }
  119. RefPtr<DynamicObject> DynamicLoader::load_from_image(unsigned flags, size_t total_tls_size)
  120. {
  121. m_valid = m_elf_image.is_valid();
  122. if (!m_valid) {
  123. dbgprintf("DynamicLoader::load_from_image failed: image is invalid\n");
  124. return nullptr;
  125. }
  126. #ifdef DYNAMIC_LOAD_VERBOSE
  127. // m_image->dump();
  128. #endif
  129. load_program_headers();
  130. m_dynamic_object = DynamicObject::construct(m_text_segment_load_address, m_dynamic_section_address);
  131. m_dynamic_object->set_tls_offset(m_tls_offset);
  132. m_dynamic_object->set_tls_size(m_tls_size);
  133. ASSERT(m_global_symbol_lookup_func);
  134. m_dynamic_object->m_global_symbol_lookup_func = m_global_symbol_lookup_func;
  135. auto rc = load_stage_2(flags, total_tls_size);
  136. if (!rc) {
  137. dbgprintf("DynamicLoader::load_from_image failed at load_stage_2\n");
  138. return nullptr;
  139. }
  140. return m_dynamic_object;
  141. }
  142. bool DynamicLoader::load_stage_2(unsigned flags, size_t total_tls_size)
  143. {
  144. ASSERT(flags & RTLD_GLOBAL);
  145. #ifdef DYNAMIC_LOAD_DEBUG
  146. m_dynamic_object->dump();
  147. #endif
  148. if (m_dynamic_object->has_text_relocations()) {
  149. // dbg() << "Someone linked non -fPIC code into " << m_filename << " :(";
  150. ASSERT(m_text_segment_load_address.get() != 0);
  151. if (0 > mprotect(m_text_segment_load_address.as_ptr(), m_text_segment_size, PROT_READ | PROT_WRITE)) {
  152. perror("mprotect .text: PROT_READ | PROT_WRITE"); // FIXME: dlerror?
  153. return false;
  154. }
  155. }
  156. do_relocations(total_tls_size);
  157. if (flags & RTLD_LAZY) {
  158. setup_plt_trampoline();
  159. }
  160. // Clean up our setting of .text to PROT_READ | PROT_WRITE
  161. if (m_dynamic_object->has_text_relocations()) {
  162. if (0 > mprotect(m_text_segment_load_address.as_ptr(), m_text_segment_size, PROT_READ | PROT_EXEC)) {
  163. perror("mprotect .text: PROT_READ | PROT_EXEC"); // FIXME: dlerror?
  164. return false;
  165. }
  166. }
  167. call_object_init_functions();
  168. VERBOSE("Loaded %s\n", m_filename.characters());
  169. return true;
  170. }
  171. void DynamicLoader::load_program_headers()
  172. {
  173. Vector<ProgramHeaderRegion> program_headers;
  174. ProgramHeaderRegion* text_region_ptr = nullptr;
  175. ProgramHeaderRegion* data_region_ptr = nullptr;
  176. ProgramHeaderRegion* tls_region_ptr = nullptr;
  177. VirtualAddress dynamic_region_desired_vaddr;
  178. m_elf_image.for_each_program_header([&](const Image::ProgramHeader& program_header) {
  179. ProgramHeaderRegion new_region;
  180. new_region.set_program_header(program_header.raw_header());
  181. program_headers.append(move(new_region));
  182. auto& region = program_headers.last();
  183. if (region.is_tls_template())
  184. tls_region_ptr = &region;
  185. else if (region.is_load()) {
  186. if (region.is_executable())
  187. text_region_ptr = &region;
  188. else
  189. data_region_ptr = &region;
  190. } else if (region.is_dynamic()) {
  191. dynamic_region_desired_vaddr = region.desired_load_address();
  192. }
  193. });
  194. ASSERT(text_region_ptr && data_region_ptr);
  195. // Process regions in order: .text, .data, .tls
  196. auto* region = text_region_ptr;
  197. void* requested_load_address = m_elf_image.is_dynamic() ? nullptr : region->desired_load_address().as_ptr();
  198. void* text_segment_begin = mmap_with_name(
  199. requested_load_address,
  200. region->required_load_size(),
  201. region->mmap_prot(),
  202. MAP_PRIVATE,
  203. m_image_fd,
  204. region->offset(),
  205. String::format("%s: .text", m_filename.characters()).characters());
  206. if (MAP_FAILED == text_segment_begin) {
  207. ASSERT_NOT_REACHED();
  208. }
  209. ASSERT(requested_load_address == nullptr || requested_load_address == text_segment_begin);
  210. m_text_segment_size = region->required_load_size();
  211. m_text_segment_load_address = VirtualAddress { (FlatPtr)text_segment_begin };
  212. if (m_elf_image.is_dynamic())
  213. m_dynamic_section_address = dynamic_region_desired_vaddr.offset(m_text_segment_load_address.get());
  214. else
  215. m_dynamic_section_address = dynamic_region_desired_vaddr;
  216. region = data_region_ptr;
  217. void* data_segment_begin = mmap_with_name(
  218. (u8*)text_segment_begin + m_text_segment_size,
  219. region->required_load_size(),
  220. region->mmap_prot(),
  221. MAP_ANONYMOUS | MAP_PRIVATE,
  222. 0,
  223. 0,
  224. String::format("%s: .data", m_filename.characters()).characters());
  225. if (MAP_FAILED == data_segment_begin) {
  226. ASSERT_NOT_REACHED();
  227. }
  228. VirtualAddress data_segment_actual_addr;
  229. if (m_elf_image.is_dynamic()) {
  230. data_segment_actual_addr = region->desired_load_address().offset((FlatPtr)text_segment_begin);
  231. } else {
  232. data_segment_actual_addr = region->desired_load_address();
  233. }
  234. memcpy(data_segment_actual_addr.as_ptr(), (u8*)m_file_mapping + region->offset(), region->size_in_image());
  235. // FIXME: Initialize the values in the TLS section. Currently, it is zeroed.
  236. }
  237. void DynamicLoader::do_relocations(size_t total_tls_size)
  238. {
  239. auto main_relocation_section = m_dynamic_object->relocation_section();
  240. main_relocation_section.for_each_relocation([&](ELF::DynamicObject::Relocation relocation) {
  241. VERBOSE("Relocation symbol: %s, type: %d\n", relocation.symbol().name(), relocation.type());
  242. FlatPtr* patch_ptr = nullptr;
  243. if (is_dynamic())
  244. patch_ptr = (FlatPtr*)(m_dynamic_object->base_address().as_ptr() + relocation.offset());
  245. else
  246. patch_ptr = (FlatPtr*)(FlatPtr)relocation.offset();
  247. // VERBOSE("dynamic object name: %s\n", dynamic_object.object_name());
  248. VERBOSE("dynamic object base address: %p\n", m_dynamic_object->base_address());
  249. VERBOSE("relocation offset: 0x%x\n", relocation.offset());
  250. VERBOSE("patch_ptr: %p\n", patch_ptr);
  251. switch (relocation.type()) {
  252. case R_386_NONE:
  253. // Apparently most loaders will just skip these?
  254. // Seems if the 'link editor' generates one something is funky with your code
  255. VERBOSE("None relocation. No symbol, no nothin.\n");
  256. break;
  257. case R_386_32: {
  258. auto symbol = relocation.symbol();
  259. VERBOSE("Absolute relocation: name: '%s', value: %p\n", symbol.name(), symbol.value());
  260. auto res = lookup_symbol(symbol);
  261. if (!res.found) {
  262. dbgln("ERROR: symbol not found: {}", symbol.name());
  263. ASSERT_NOT_REACHED();
  264. }
  265. u32 symbol_address = res.address;
  266. *patch_ptr += symbol_address;
  267. VERBOSE(" Symbol address: %p\n", *patch_ptr);
  268. break;
  269. }
  270. case R_386_PC32: {
  271. auto symbol = relocation.symbol();
  272. VERBOSE("PC-relative relocation: '%s', value: %p\n", symbol.name(), symbol.value());
  273. auto res = lookup_symbol(symbol);
  274. ASSERT(res.found);
  275. u32 relative_offset = (res.address - (FlatPtr)(m_dynamic_object->base_address().as_ptr() + relocation.offset()));
  276. *patch_ptr += relative_offset;
  277. VERBOSE(" Symbol address: %p\n", *patch_ptr);
  278. break;
  279. }
  280. case R_386_GLOB_DAT: {
  281. auto symbol = relocation.symbol();
  282. VERBOSE("Global data relocation: '%s', value: %p\n", symbol.name(), symbol.value());
  283. auto res = lookup_symbol(symbol);
  284. if (!res.found) {
  285. // We do not support these
  286. // TODO: Can we tell gcc not to generate the piece of code that uses these?
  287. // (--disable-tm-clone-registry flag in gcc conifugraion?)
  288. if (!strcmp(symbol.name(), "__deregister_frame_info") || !strcmp(symbol.name(), "_ITM_registerTMCloneTable")
  289. || !strcmp(symbol.name(), "_ITM_deregisterTMCloneTable") || !strcmp(symbol.name(), "__register_frame_info")) {
  290. break;
  291. }
  292. // The "__do_global_dtors_aux" function in libgcc_s.so needs this symbol,
  293. // but we do not use that function so we don't actually need to resolve this symbol.
  294. // The reason we can't resolve it here is that the symbol is defined in libc.so,
  295. // but there's a circular dependecy between libgcc_s.so and libc.so,
  296. // we deal with it by first loading libgcc_s and then libc.
  297. // So we cannot find this symbol at this time (libc is not yet loaded).
  298. if (m_filename == "libgcc_s.so" && !strcmp(symbol.name(), "__cxa_finalize")) {
  299. break;
  300. }
  301. // Symbol not found
  302. ASSERT_NOT_REACHED();
  303. }
  304. VERBOSE("was symbol found? %d, address: 0x%x\n", res.found, res.address);
  305. VERBOSE("object: %s\n", m_filename.characters());
  306. if (!res.found) {
  307. // TODO this is a hack
  308. ASSERT(!strcmp(symbol.name(), "__deregister_frame_info") || !strcmp(symbol.name(), "_ITM_registerTMCloneTable")
  309. || !strcmp(symbol.name(), "_ITM_deregisterTMCloneTable") || !strcmp(symbol.name(), "__register_frame_info"));
  310. ASSERT_NOT_REACHED();
  311. return IterationDecision::Continue;
  312. }
  313. // ASSERT(res.found);
  314. u32 symbol_location = res.address;
  315. ASSERT(symbol_location != (FlatPtr)m_dynamic_object->base_address().as_ptr());
  316. *patch_ptr = symbol_location;
  317. VERBOSE(" Symbol address: %p\n", *patch_ptr);
  318. break;
  319. }
  320. case R_386_RELATIVE: {
  321. // FIXME: According to the spec, R_386_relative ones must be done first.
  322. // We could explicitly do them first using m_number_of_relocatoins from DT_RELCOUNT
  323. // However, our compiler is nice enough to put them at the front of the relocations for us :)
  324. VERBOSE("Load address relocation at offset %X\n", relocation.offset());
  325. 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());
  326. *patch_ptr += (FlatPtr)m_dynamic_object->base_address().as_ptr(); // + addend for RelA (addend for Rel is stored at addr)
  327. break;
  328. }
  329. case R_386_TLS_TPOFF32:
  330. case R_386_TLS_TPOFF: {
  331. VERBOSE("Relocation type: R_386_TLS_TPOFF at offset %X\n", relocation.offset());
  332. auto symbol = relocation.symbol();
  333. // For some reason, LibC has a R_386_TLS_TPOFF that referes to the undefined symbol.. huh
  334. if (relocation.symbol_index() == 0)
  335. break;
  336. VERBOSE("Symbol index: %d\n", symbol.index());
  337. VERBOSE("Symbol is_undefined?: %d\n", symbol.is_undefined());
  338. VERBOSE("TLS relocation: '%s', value: %p\n", symbol.name(), symbol.value());
  339. auto res = lookup_symbol(symbol);
  340. if (!res.found)
  341. break;
  342. ASSERT(res.found);
  343. u32 symbol_value = res.value;
  344. VERBOSE("symbol value: %d\n", symbol_value);
  345. const auto dynamic_object_of_symbol = res.dynamic_object;
  346. ASSERT(dynamic_object_of_symbol);
  347. size_t offset_of_tls_end = dynamic_object_of_symbol->tls_offset().value() + dynamic_object_of_symbol->tls_size().value();
  348. // size_t offset_of_tls_end = tls_offset() + tls_size();
  349. VERBOSE("patch ptr: 0x%x\n", patch_ptr);
  350. VERBOSE("tls end offset: %d, total tls size: %d\n", offset_of_tls_end, total_tls_size);
  351. *patch_ptr = (offset_of_tls_end - total_tls_size - symbol_value - sizeof(Elf32_Addr));
  352. VERBOSE("*patch ptr: %d\n", (i32)*patch_ptr);
  353. break;
  354. }
  355. default:
  356. // Raise the alarm! Someone needs to implement this relocation type
  357. VERBOSE("Found a new exciting relocation type %d\n", relocation.type());
  358. // printf("DynamicLoader: Found unknown relocation type %d\n", relocation.type());
  359. ASSERT_NOT_REACHED();
  360. break;
  361. }
  362. return IterationDecision::Continue;
  363. });
  364. VERBOSE("plt relocations: 0x%x", m_dynamic_object->plt_relocation_section().address());
  365. VERBOSE("plt relocation count: 0x%x", m_dynamic_object->plt_relocation_section().address());
  366. VERBOSE("plt size: %d\n", m_dynamic_object->plt_relocation_section().size());
  367. VERBOSE("plt entry size: 0x%x\n", m_dynamic_object->plt_relocation_section().entry_size());
  368. // Handle PLT Global offset table relocations.
  369. m_dynamic_object->plt_relocation_section().for_each_relocation([&](const DynamicObject::Relocation& relocation) {
  370. // FIXME: Or BIND_NOW flag passed in?
  371. if (m_dynamic_object->must_bind_now() || s_always_bind_now) {
  372. // Eagerly BIND_NOW the PLT entries, doing all the symbol looking goodness
  373. // The patch method returns the address for the LAZY fixup path, but we don't need it here
  374. VERBOSE("patching plt reloaction: 0x%x\n", relocation.offset_in_section());
  375. [[maybe_unused]] auto rc = m_dynamic_object->patch_plt_entry(relocation.offset_in_section());
  376. } else {
  377. ASSERT(relocation.type() == R_386_JMP_SLOT);
  378. u8* relocation_address = relocation.address().as_ptr();
  379. if (m_elf_image.is_dynamic())
  380. *(u32*)relocation_address += (FlatPtr)m_dynamic_object->base_address().as_ptr();
  381. }
  382. return IterationDecision::Continue;
  383. });
  384. VERBOSE("Done relocating!\n");
  385. }
  386. // Defined in <arch>/plt_trampoline.S
  387. extern "C" void _plt_trampoline() __attribute__((visibility("hidden")));
  388. void DynamicLoader::setup_plt_trampoline()
  389. {
  390. ASSERT(m_dynamic_object);
  391. VirtualAddress got_address = m_dynamic_object->plt_got_base_address();
  392. FlatPtr* got_ptr = (FlatPtr*)got_address.as_ptr();
  393. got_ptr[1] = (FlatPtr)m_dynamic_object.ptr();
  394. got_ptr[2] = (FlatPtr)&_plt_trampoline;
  395. 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]);
  396. }
  397. // Called from our ASM routine _plt_trampoline.
  398. // Tell the compiler that it might be called from other places:
  399. extern "C" Elf32_Addr _fixup_plt_entry(DynamicObject* object, u32 relocation_offset);
  400. extern "C" Elf32_Addr _fixup_plt_entry(DynamicObject* object, u32 relocation_offset)
  401. {
  402. return object->patch_plt_entry(relocation_offset);
  403. }
  404. void DynamicLoader::call_object_init_functions()
  405. {
  406. typedef void (*InitFunc)();
  407. if (m_dynamic_object->has_init_section()) {
  408. auto init_function = (InitFunc)(m_dynamic_object->init_section().address().as_ptr());
  409. VERBOSE("Calling DT_INIT at %p\n", init_function);
  410. (init_function)();
  411. }
  412. if (m_dynamic_object->has_init_array_section()) {
  413. auto init_array_section = m_dynamic_object->init_array_section();
  414. InitFunc* init_begin = (InitFunc*)(init_array_section.address().as_ptr());
  415. InitFunc* init_end = init_begin + init_array_section.entry_count();
  416. while (init_begin != init_end) {
  417. // Android sources claim that these can be -1, to be ignored.
  418. // 0 definitely shows up. Apparently 0/-1 are valid? Confusing.
  419. if (!*init_begin || ((FlatPtr)*init_begin == (FlatPtr)-1))
  420. continue;
  421. VERBOSE("Calling DT_INITARRAY entry at %p\n", *init_begin);
  422. (*init_begin)();
  423. ++init_begin;
  424. }
  425. }
  426. }
  427. u32 DynamicLoader::ProgramHeaderRegion::mmap_prot() const
  428. {
  429. int prot = 0;
  430. prot |= is_executable() ? PROT_EXEC : 0;
  431. prot |= is_readable() ? PROT_READ : 0;
  432. prot |= is_writable() ? PROT_WRITE : 0;
  433. return prot;
  434. }
  435. DynamicObject::SymbolLookupResult DynamicLoader::lookup_symbol(const ELF::DynamicObject::Symbol& symbol) const
  436. {
  437. return m_dynamic_object->lookup_symbol(symbol);
  438. }
  439. } // end namespace ELF