• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_HXX
18 #define ELF_SECTION_HXX
19 
20 #include "utils/raw_ostream.h"
21 
22 #include <llvm/Support/raw_ostream.h>
23 
24 #include "ELFSectionHeader.h"
25 #include "ELFSectionStrTab.h"
26 #include "ELFSectionSymTab.h"
27 #include "ELFSectionProgBits.h"
28 #include "ELFSectionNoBits.h"
29 #include "ELFSectionRelTable.h"
30 
31 template <unsigned Bitwidth>
32 template <typename Archiver>
33 inline ELFSection<Bitwidth> *
read(Archiver & AR,ELFObjectTy * owner,ELFSectionHeaderTy const * sh)34 ELFSection<Bitwidth>::read(Archiver &AR,
35                            ELFObjectTy *owner,
36                            ELFSectionHeaderTy const *sh) {
37   using namespace std;
38 
39   switch (sh->getType()) {
40     default:
41       // Uknown type of ELF section.  Return NULL.
42       //llvm::errs() << "WARNING: Unknown section type.\n";
43       return 0;
44 
45     case SHT_STRTAB:
46       return ELFSectionStrTabTy::read(AR, sh);
47 
48     case SHT_SYMTAB:
49       return ELFSectionSymTabTy::read(AR, owner, sh);
50 
51     case SHT_PROGBITS:
52       return ELFSectionProgBitsTy::read(AR, owner, sh);
53 
54     case SHT_NOBITS:
55       return ELFSectionNoBitsTy::read(AR, sh);
56 
57     case SHT_REL:
58     case SHT_RELA:
59       return ELFSectionRelTableTy::read(AR, sh);
60 
61     case SHT_NULL:
62       // TODO: Not Yet Implemented
63       return 0;
64   };
65 }
66 
67 #endif // ELF_SECTION_HXX
68