Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 1 | //===-- ObjectFileJIT.h -----------------------------------------*- C++ -*-===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame^] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | #ifndef liblldb_ObjectFileJIT_h_ |
| 10 | #define liblldb_ObjectFileJIT_h_ |
| 11 | |
| 12 | #include "lldb/Core/Address.h" |
| 13 | #include "lldb/Symbol/ObjectFile.h" |
| 14 | |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 15 | //---------------------------------------------------------------------- |
| 16 | // This class needs to be hidden as eventually belongs in a plugin that |
| 17 | // will export the ObjectFile protocol |
| 18 | //---------------------------------------------------------------------- |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 19 | class ObjectFileJIT : public lldb_private::ObjectFile { |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 20 | public: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 21 | ObjectFileJIT(const lldb::ModuleSP &module_sp, |
| 22 | const lldb::ObjectFileJITDelegateSP &delegate_sp); |
Eugene Zelenko | 8157a88 | 2015-10-23 16:56:07 +0000 | [diff] [blame] | 23 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 24 | ~ObjectFileJIT() override; |
Eugene Zelenko | 8157a88 | 2015-10-23 16:56:07 +0000 | [diff] [blame] | 25 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 26 | //------------------------------------------------------------------ |
| 27 | // Static Functions |
| 28 | //------------------------------------------------------------------ |
| 29 | static void Initialize(); |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 30 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 31 | static void Terminate(); |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 32 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 33 | static lldb_private::ConstString GetPluginNameStatic(); |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 34 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 35 | static const char *GetPluginDescriptionStatic(); |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 36 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 37 | static lldb_private::ObjectFile * |
| 38 | CreateInstance(const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp, |
| 39 | lldb::offset_t data_offset, const lldb_private::FileSpec *file, |
| 40 | lldb::offset_t file_offset, lldb::offset_t length); |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 41 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 42 | static lldb_private::ObjectFile *CreateMemoryInstance( |
| 43 | const lldb::ModuleSP &module_sp, lldb::DataBufferSP &data_sp, |
| 44 | const lldb::ProcessSP &process_sp, lldb::addr_t header_addr); |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 45 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 46 | static size_t GetModuleSpecifications(const lldb_private::FileSpec &file, |
| 47 | lldb::DataBufferSP &data_sp, |
| 48 | lldb::offset_t data_offset, |
| 49 | lldb::offset_t file_offset, |
| 50 | lldb::offset_t length, |
| 51 | lldb_private::ModuleSpecList &specs); |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 52 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 53 | //------------------------------------------------------------------ |
| 54 | // Member Functions |
| 55 | //------------------------------------------------------------------ |
| 56 | bool ParseHeader() override; |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 57 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 58 | bool SetLoadAddress(lldb_private::Target &target, lldb::addr_t value, |
| 59 | bool value_is_offset) override; |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 60 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 61 | lldb::ByteOrder GetByteOrder() const override; |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 62 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 63 | bool IsExecutable() const override; |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 64 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 65 | uint32_t GetAddressByteSize() const override; |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 66 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 67 | lldb_private::Symtab *GetSymtab() override; |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 68 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 69 | bool IsStripped() override; |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 70 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 71 | void CreateSections(lldb_private::SectionList &unified_section_list) override; |
Eugene Zelenko | 8157a88 | 2015-10-23 16:56:07 +0000 | [diff] [blame] | 72 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 73 | void Dump(lldb_private::Stream *s) override; |
Eugene Zelenko | 8157a88 | 2015-10-23 16:56:07 +0000 | [diff] [blame] | 74 | |
Pavel Labath | f760f5a | 2019-01-03 10:37:19 +0000 | [diff] [blame] | 75 | lldb_private::ArchSpec GetArchitecture() override; |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 76 | |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 77 | bool GetUUID(lldb_private::UUID *uuid) override; |
| 78 | |
| 79 | uint32_t GetDependentModules(lldb_private::FileSpecList &files) override; |
| 80 | |
Ed Maste | d13f691 | 2017-10-02 14:35:07 +0000 | [diff] [blame] | 81 | size_t ReadSectionData(lldb_private::Section *section, |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 82 | lldb::offset_t section_offset, void *dst, |
Ed Maste | d13f691 | 2017-10-02 14:35:07 +0000 | [diff] [blame] | 83 | size_t dst_len) override; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 84 | |
| 85 | size_t |
Ed Maste | d13f691 | 2017-10-02 14:35:07 +0000 | [diff] [blame] | 86 | ReadSectionData(lldb_private::Section *section, |
| 87 | lldb_private::DataExtractor §ion_data) override; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 88 | |
| 89 | lldb_private::Address GetEntryPointAddress() override; |
| 90 | |
Pavel Labath | d1e3fe2 | 2018-12-11 15:21:15 +0000 | [diff] [blame] | 91 | lldb_private::Address GetBaseAddress() override; |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 92 | |
| 93 | ObjectFile::Type CalculateType() override; |
| 94 | |
| 95 | ObjectFile::Strata CalculateStrata() override; |
| 96 | |
| 97 | //------------------------------------------------------------------ |
| 98 | // PluginInterface protocol |
| 99 | //------------------------------------------------------------------ |
| 100 | lldb_private::ConstString GetPluginName() override; |
| 101 | |
| 102 | uint32_t GetPluginVersion() override; |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 103 | |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 104 | protected: |
Kate Stone | b9c1b51 | 2016-09-06 20:57:50 +0000 | [diff] [blame] | 105 | lldb::ObjectFileJITDelegateWP m_delegate_wp; |
Greg Clayton | 23f8c95 | 2014-03-24 23:10:19 +0000 | [diff] [blame] | 106 | }; |
| 107 | |
Eugene Zelenko | 8157a88 | 2015-10-23 16:56:07 +0000 | [diff] [blame] | 108 | #endif // liblldb_ObjectFileJIT_h_ |