| Zonr Chang | 0f9cad9 | 2012-04-13 14:35:45 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2012, The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef BCC_EXECUTION_ENGINE_ELF_OBJECT_LOADER_IMPL_H |
| 18 | #define BCC_EXECUTION_ENGINE_ELF_OBJECT_LOADER_IMPL_H |
| 19 | |
| 20 | #include "ObjectLoaderImpl.h" |
| 21 | |
| 22 | // ELFObject and ELFSectionSymTab comes from librsloader. They're both |
| 23 | // defined under global scope without a namespace enclosed. |
| 24 | template <unsigned Bitwidth> |
| 25 | class ELFObject; |
| 26 | |
| 27 | template <unsigned Bitwidth> |
| 28 | class ELFSectionSymTab; |
| 29 | |
| 30 | namespace bcc { |
| 31 | |
| 32 | class ELFObjectLoaderImpl : public ObjectLoaderImpl { |
| 33 | private: |
| WeiTang | e524a6f | 2014-04-04 23:38:30 +0800 | [diff] [blame] | 34 | #ifdef __LP64__ |
| 35 | ELFObject<64> *mObject; |
| 36 | ELFSectionSymTab<64> *mSymTab; |
| 37 | #else |
| Zonr Chang | 0f9cad9 | 2012-04-13 14:35:45 +0800 | [diff] [blame] | 38 | ELFObject<32> *mObject; |
| 39 | ELFSectionSymTab<32> *mSymTab; |
| WeiTang | e524a6f | 2014-04-04 23:38:30 +0800 | [diff] [blame] | 40 | #endif |
| Zonr Chang | 0f9cad9 | 2012-04-13 14:35:45 +0800 | [diff] [blame] | 41 | |
| 42 | public: |
| 43 | ELFObjectLoaderImpl() : ObjectLoaderImpl(), mObject(NULL), mSymTab(NULL) { } |
| 44 | |
| 45 | virtual bool load(const void *pMem, size_t pMemSize); |
| 46 | |
| 47 | virtual bool relocate(SymbolResolverInterface &pResolver); |
| 48 | |
| 49 | virtual bool prepareDebugImage(void *pDebugImg, size_t pDebugImgSize); |
| 50 | |
| 51 | virtual void *getSymbolAddress(const char *pName) const; |
| 52 | |
| Shih-wei Liao | 9795754 | 2012-07-22 15:42:53 -0700 | [diff] [blame] | 53 | virtual size_t getSymbolSize(const char *pName) const; |
| 54 | |
| Chris Wailes | 5e7d876 | 2014-07-25 18:02:32 -0700 | [diff] [blame^] | 55 | virtual bool getSymbolNameList(std::vector<const char *>& pNameList, |
| Shih-wei Liao | 9795754 | 2012-07-22 15:42:53 -0700 | [diff] [blame] | 56 | ObjectLoader::SymbolType pType) const; |
| Zonr Chang | 0f9cad9 | 2012-04-13 14:35:45 +0800 | [diff] [blame] | 57 | ~ELFObjectLoaderImpl(); |
| 58 | }; |
| 59 | |
| 60 | } // end namespace bcc |
| 61 | |
| 62 | #endif // BCC_EXECUTION_ENGINE_ELF_OBJECT_LOADER_IMPL_H |