author | Martin Trojer <martin.trojer@nokia.com> |
Fri, 15 Jan 2010 09:07:44 +0000 | |
changeset 34 | 92d87f2e53c2 |
permissions | -rwxr-xr-x |
34
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
1 |
/* |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
2 |
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
3 |
* All rights reserved. |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
4 |
* |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
5 |
* This program is free software: you can redistribute it and/or modify |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU Lesser General Public License as published by |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
7 |
* the Free Software Foundation, either version 3 of the License, or |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
8 |
* (at your option) any later version. |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
9 |
* |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
10 |
* This program is distributed in the hope that it will be useful, |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
13 |
* GNU Lesser General Public License for more details. |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
14 |
* |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU Lesser General Public License |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
16 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
17 |
*/ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
18 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
19 |
#include <string.h> |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
20 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
21 |
#include "elfsectionmanager.h" |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
22 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
23 |
void ElfSectionManager::GetFileFragmentData(FileFragmentData & aFileFragmentData ){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
24 |
int nSections = iSections.size(); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
25 |
if (nSections > 0){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
26 |
iData = new Elf32_Shdr[nSections]; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
27 |
Elf32_Shdr * p = iData; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
28 |
SectionList::iterator aSection = iSections.begin(); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
29 |
SectionList::iterator end = iSections.end(); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
30 |
while (aSection != end) { |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
31 |
*p = aSection->GetSectionHeader().iElf32Shdr; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
32 |
p++; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
33 |
aSection++; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
34 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
35 |
SetFileFragmentData(aFileFragmentData, Size(), reinterpret_cast<char *>(iData)); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
36 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
37 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
38 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
39 |
size_t ElfSectionManager::Size(){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
40 |
return SectionHeaderSize(); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
41 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
42 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
43 |
void ElfSectionManager::DeleteFileFragmentData(){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
44 |
if (iData) { |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
45 |
Elf32_Shdr * d = iData; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
46 |
iData = NULL; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
47 |
delete[] d; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
48 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
49 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
50 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
51 |
void ElfSectionManager::AddData(){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
52 |
AddData(iOutputFile); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
53 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
54 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
55 |
void ElfSectionManager::AddData(OutputFile & aOutputFile){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
56 |
if (iSections.size() > 0) { |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
57 |
SectionList::iterator aSection = iSections.begin(); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
58 |
SectionList::iterator end = iSections.end(); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
59 |
while (aSection != end) { |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
60 |
aSection->AddData(aOutputFile); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
61 |
aSection++; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
62 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
63 |
AddSectionTable(); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
64 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
65 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
66 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
67 |
void ElfSectionManager::EnsureSectionStringTableSectionAdded(){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
68 |
if (iSectionStringTableSectionAdded) return; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
69 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
70 |
// set iSectionStringTableSectionAdded true now so we don't do the next bit twice; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
71 |
iSectionStringTableSectionAdded = true; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
72 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
73 |
// first create the UNDEF section |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
74 |
ElfSectionNoData * aUndefData = new ElfSectionNoData(); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
75 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
76 |
Elf32_Shdr undef; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
77 |
undef.sh_name = 0; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
78 |
undef.sh_type = SHT_NULL; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
79 |
undef.sh_flags = 0; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
80 |
undef.sh_addr = 0; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
81 |
undef.sh_offset = 0; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
82 |
undef.sh_size = 0; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
83 |
undef.sh_link = 0; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
84 |
undef.sh_info = 0; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
85 |
undef.sh_addralign = 0; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
86 |
undef.sh_entsize = 0; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
87 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
88 |
ElfSection aUndefSection(aUndefData, "", undef); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
89 |
AddSection(aUndefSection); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
90 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
91 |
ElfSectionElfData * aSectionStringTableSectionData = new ElfSectionElfData(iStringTable); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
92 |
Elf32_Shdr shdr; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
93 |
shdr.sh_name = 0; // for now. |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
94 |
shdr.sh_type = SHT_STRTAB; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
95 |
shdr.sh_flags = 0; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
96 |
shdr.sh_addr = 0; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
97 |
shdr.sh_offset = 0; // for now |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
98 |
shdr.sh_size = 0; // for now. |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
99 |
shdr.sh_link = SHN_UNDEF; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
100 |
shdr.sh_info = 0; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
101 |
shdr.sh_addralign = 0; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
102 |
shdr.sh_entsize = 0; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
103 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
104 |
ElfSection aSectionStringTableSection(aSectionStringTableSectionData, ".shstrtab", shdr); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
105 |
AddSection(aSectionStringTableSection); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
106 |
iElf32Header.SetSectionStringNdx(iSections.size() - 1); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
107 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
108 |
void ElfSectionManager::AddSection(ElfSection & aSection){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
109 |
EnsureSectionStringTableSectionAdded(); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
110 |
if (aSection.GetName().size() > 0){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
111 |
// rename sections for GDB (yuk!) |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
112 |
String sectionName(aSection.GetName()); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
113 |
String ro("ER_RO"); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
114 |
String text(".text"); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
115 |
if (sectionName == ro){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
116 |
sectionName = text; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
117 |
} else { |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
118 |
String rw("ER_RW"); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
119 |
String data(".data"); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
120 |
if (sectionName == rw){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
121 |
sectionName = data; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
122 |
} else { |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
123 |
String zi("ER_ZI"); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
124 |
String bss(".bss"); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
125 |
if (sectionName == zi) |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
126 |
sectionName = bss; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
127 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
128 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
129 |
size_t nameOffset = iStringTable.AddName(sectionName); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
130 |
aSection.SetNameOffset(nameOffset); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
131 |
} else { |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
132 |
// use the initial Null String. |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
133 |
size_t nameOffset = iStringTable.AllocateInitialNullString(); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
134 |
aSection.SetNameOffset(nameOffset); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
135 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
136 |
aSection.SetIndex(iSections.size()); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
137 |
iSections.push_back(aSection); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
138 |
iElf32Header.AddSectionHdr(); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
139 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
140 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
141 |
size_t ElfSectionManager::SectionHeaderSize(){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
142 |
return iSections.size() * sizeof(Elf32_Shdr); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
143 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
144 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
145 |
void ElfSectionManager::AddSectionStringTable(){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
146 |
// Assume the section header already setup and we've got hold of it. We need to say where the strings ended up. |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
147 |
const FileFragment & aSectionTableFrag = iOutputFile.GetFileFragment(this); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
148 |
SetOffset(aSectionTableFrag.GetOffset()); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
149 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
150 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
151 |
void ElfSectionManager::AddSectionTable(){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
152 |
const FileFragment & aSectionTableFrag = iOutputFile.GetFileFragment(this); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
153 |
SetOffset(aSectionTableFrag.GetOffset()); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
154 |
iElf32Header.SetSectionHdrOffset(GetOffset()); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
155 |
} |