Home | History | Annotate | Download | only in include
      1 /*
      2  * Copyright 2011, 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 ELF_SECTION_SYMTAB_H
     18 #define ELF_SECTION_SYMTAB_H
     19 
     20 #include "ELFTypes.h"
     21 
     22 #include <llvm/ADT/StringMap.h>
     23 
     24 #include <vector>
     25 #include <string>
     26 
     27 template <unsigned Bitwidth>
     28 class ELFSectionSymTab : public ELFSection<Bitwidth> {
     29 public:
     30   ELF_TYPE_INTRO_TO_TEMPLATE_SCOPE(Bitwidth);
     31 
     32 private:
     33   std::vector<ELFSymbolTy *> table;
     34   llvm::StringMap<ELFSymbolTy *> name_map;
     35 
     36 private:
     37   ELFSectionSymTab() { }
     38 
     39 public:
     40   ~ELFSectionSymTab();
     41 
     42   template <typename Archiver>
     43   static ELFSectionSymTab *
     44   read(Archiver &AR, ELFObjectTy *owner, ELFSectionHeaderTy const *sh);
     45 
     46   virtual void print() const;
     47 
     48   size_t size() const {
     49     return table.size();
     50   }
     51 
     52   ELFSymbolTy const *operator[](size_t index) const {
     53     return table[index];
     54   }
     55 
     56   ELFSymbolTy *operator[](size_t index) {
     57     return table[index];
     58   }
     59 
     60   void buildNameMap();
     61 
     62   ELFSymbolTy const *getByName(std::string const &name) const;
     63 
     64   ELFSymbolTy *getByName(std::string const &name) {
     65     return const_cast<ELFSymbolTy *>(
     66            const_cast<ELFSectionSymTabTy const *>(this)->getByName(name));
     67   }
     68 
     69   size_t getFuncCount() const;
     70 
     71   void getFuncNameList(size_t size, char const **list) const;
     72 
     73   size_t getExternFuncCount() const;
     74 
     75 };
     76 
     77 #include "impl/ELFSectionSymTab.hxx"
     78 
     79 #endif // ELF_SECTION_SYMTAB_H
     80