|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * |
|
5 * This program is free software: you can redistribute it and/or modify |
|
6 * it under the terms of the GNU Lesser General Public License as published by |
|
7 * the Free Software Foundation, either version 3 of the License, or |
|
8 * (at your option) any later version. |
|
9 * |
|
10 * This program is distributed in the hope that it will be useful, |
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 * GNU Lesser General Public License for more details. |
|
14 * |
|
15 * You should have received a copy of the GNU Lesser General Public License |
|
16 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
17 */ |
|
18 |
|
19 #ifndef ELFSECTIONMANAGER_H_ |
|
20 #define ELFSECTIONMANAGER_H_ |
|
21 |
|
22 #include <vector> |
|
23 |
|
24 #include "filefragment.h" |
|
25 // |
|
26 // Copyright (c) 2008 Symbian Software Ltd. All rights reserved. |
|
27 // |
|
28 |
|
29 #include "elfstringtable.h" |
|
30 #include "outputfile.h" |
|
31 #include "elfheader.h" |
|
32 #include "e32romimage.h" |
|
33 #include "elfsection.h" |
|
34 #include "defs.h" // String |
|
35 |
|
36 |
|
37 class ElfSectionHeaderStringTable : public ElfStringTable { |
|
38 public: |
|
39 size_t AddName(String aName) { |
|
40 return AddString(aName); |
|
41 } |
|
42 |
|
43 }; |
|
44 |
|
45 class ElfSectionManager : public FileFragmentOwner { |
|
46 public: |
|
47 ElfSectionManager(Elf32Header & aElf32Header, E32RomImage & aRomImage, OutputFile & aOutputFile) : |
|
48 iElf32Header(aElf32Header), iRomImage(aRomImage), |
|
49 iOutputFile(aOutputFile), iOffset(0), iData(NULL), |
|
50 iSectionStringTableSectionAdded(false) |
|
51 {} |
|
52 |
|
53 // The FileFragmentOwner protocol |
|
54 virtual void GetFileFragmentData(FileFragmentData & aFileFragmentData ); |
|
55 virtual size_t Size(); |
|
56 virtual void DeleteFileFragmentData(); |
|
57 virtual void AddData(OutputFile & aOutputFile); |
|
58 |
|
59 void AddData(); |
|
60 void AddSection(ElfSection & aSection); |
|
61 |
|
62 int NumSections() { return iSections.size(); } |
|
63 |
|
64 private: |
|
65 // Don't want one of these to be copied |
|
66 ElfSectionManager(const ElfSectionManager & aElfSectionManager); |
|
67 |
|
68 ElfSectionManager & operator=(const ElfSectionManager & aElfSectionManager); |
|
69 |
|
70 private: |
|
71 size_t SectionHeaderSize(); |
|
72 void AddSectionStringTable(); |
|
73 void AddSectionTable(); |
|
74 void EnsureSectionStringTableSectionAdded(); |
|
75 |
|
76 private: |
|
77 typedef std::vector<ElfSection> SectionList; |
|
78 Elf32Header & iElf32Header; |
|
79 E32RomImage & iRomImage; |
|
80 OutputFile & iOutputFile; |
|
81 SectionList iSections; |
|
82 size_t iOffset; |
|
83 ElfSectionHeaderStringTable iStringTable; |
|
84 Elf32_Shdr * iData; |
|
85 bool iSectionStringTableSectionAdded; |
|
86 |
|
87 }; |
|
88 |
|
89 #endif /*ELFSECTIONMANAGER_H_*/ |