|
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 ELFROM_H_ |
|
20 #define ELFROM_H_ |
|
21 |
|
22 #include <vector> |
|
23 // |
|
24 // Copyright (c) 2008 Symbian Software Ltd. All rights reserved. |
|
25 // |
|
26 |
|
27 #include <libelf.h> |
|
28 |
|
29 #include "romdetails.h" |
|
30 #include "outputfile.h" |
|
31 #include "elfheader.h" |
|
32 #include "e32romimage.h" |
|
33 #include "elfphdr.h" |
|
34 #include "elfsectionmanager.h" |
|
35 #include "elfsymboltablemanager.h" |
|
36 #include "dwarfmanager.h" |
|
37 |
|
38 class ElfRom { |
|
39 public: |
|
40 ElfRom(RomDetails * aRomDetails) : |
|
41 iRomDetails(aRomDetails), iOutputFile(aRomDetails->iElfRomFile), |
|
42 iE32RomImage(aRomDetails->iRomFile), |
|
43 iElfSectionManager(iElf32Header, iE32RomImage, iOutputFile), |
|
44 iElfSymbolTableManager(iElf32Header, iE32RomImage, iOutputFile, iElfSectionManager), |
|
45 iDwarfManager(iElfSectionManager, aRomDetails, iOutputFile), |
|
46 iDwarfFound(false) |
|
47 {} |
|
48 void SetupE32RomData(); |
|
49 void SetupELFRomData(); |
|
50 void AddData(); |
|
51 void Dump(); |
|
52 |
|
53 private: |
|
54 typedef std::vector< Elf32_Shdr * > Elf32_Shdr_List; |
|
55 |
|
56 private: |
|
57 void SetupRomElf32_EHdr(); |
|
58 void SetupRomImage(); |
|
59 void SetupProgramHeaderTable(); |
|
60 size_t AddBootStrapProgramHeader(); |
|
61 size_t SetupProgramHeaders(XIPFileDetails & aXIPFileDetails, size_t offset, int addend); |
|
62 void SetupAuxilarySections(); |
|
63 void SetupLogFile(); |
|
64 void SetupSectionHeaderTable(); |
|
65 void SetupSectionHeaders(XIPFileDetails & aXIPFileDetails); |
|
66 void SetupSectionHeaders(XIPFileDetails & aXIPFileDetails, Elf * e, size_t shstrndx); |
|
67 void SetUpSegmentInfo(XIPFileDetails & aXIPFileDetails, Elf * e); |
|
68 size_t AddRoSectionHeader(XIPFileDetails & aXIPFileDetails, Elf32_Shdr * aShdr, char * aName); |
|
69 size_t AddRwSectionHeader(XIPFileDetails & aXIPFileDetails, Elf32_Shdr * aShdr, char * aName); |
|
70 size_t AddBssSectionHeader(XIPFileDetails & aXIPFileDetails, Elf32_Shdr * aShdr, char * aName); |
|
71 size_t AddROMSectionHeader(XIPFileDetails & aXIPFileDetails, Elf32_Shdr * aShdr, char * aName, size_t aOffset); |
|
72 size_t AddFinalHeader(size_t offset); |
|
73 void SetupSymbolTable(); |
|
74 void SetupDwarfSections(); |
|
75 |
|
76 private: |
|
77 RomDetails * iRomDetails; |
|
78 OutputFile iOutputFile; |
|
79 |
|
80 Elf32Header iElf32Header; |
|
81 E32RomImage iE32RomImage; |
|
82 |
|
83 ElfPHdr iBootStrapPHdr; |
|
84 |
|
85 typedef std::vector<ElfPHdr> ElfPHdrList; |
|
86 ElfPHdrList iElfPHdrList; |
|
87 |
|
88 ElfSectionManager iElfSectionManager; |
|
89 ElfSymbolTableManager iElfSymbolTableManager; |
|
90 DwarfManager iDwarfManager; |
|
91 |
|
92 bool iDwarfFound; |
|
93 |
|
94 }; |
|
95 #endif /*ELFROM_H_*/ |