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 "outputfile.h" |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
20 |
#include "inputfile.h" |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
21 |
#include "filefragment.h" |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
22 |
#include "elfsection.h" |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
23 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
24 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
25 |
ElfSection & ElfSection::operator=(const ElfSection & aSection) { |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
26 |
iSectionName = aSection.iSectionName; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
27 |
iSectionHdr = aSection.iSectionHdr; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
28 |
iSectionData = aSection.iSectionData->Clone(); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
29 |
iIndex = aSection.iIndex; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
30 |
return *this; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
31 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
32 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
33 |
ElfSection::ElfSection(const ElfSection & aSection){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
34 |
*this = aSection; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
35 |
} |
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 |
ElfSectionRomData::ElfSectionRomData(const ElfSectionRomData & aData) { |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
38 |
iOffset = aData.iOffset; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
39 |
iSize = aData.iSize; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
40 |
} |
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 |
ElfSectionRomData * ElfSectionRomData::Clone(){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
43 |
return new ElfSectionRomData(*this); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
44 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
45 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
46 |
ElfSectionElfData::ElfSectionElfData(const ElfSectionElfData & aData) : |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
47 |
iSource(aData.iSource) |
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 |
iOffset = aData.iOffset; |
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 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
52 |
ElfSectionElfData * ElfSectionElfData::Clone(){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
53 |
return new ElfSectionElfData(*this); |
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 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
56 |
void ElfSectionElfData::AddData(OutputFile & aOutputFile){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
57 |
iSource.AddData(aOutputFile); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
58 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
59 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
60 |
void ElfSectionElfData::GetFileFragmentData(FileFragmentData & aFileFragmentData ){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
61 |
iSource.GetFileFragmentData(aFileFragmentData); |
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 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
64 |
void ElfSectionElfData::DeleteFileFragmentData(){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
65 |
iSource.DeleteFileFragmentData(); |
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 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
68 |
size_t ElfSectionElfData::Size(){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
69 |
return iSource.Size(); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
70 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
71 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
72 |
size_t ElfSectionElfData::GetOffset(){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
73 |
return iSource.GetOffset(); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
74 |
} |
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 |
ElfSectionFileData::ElfSectionFileData(const ElfSectionFileData & aData) { |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
77 |
iOffset = aData.iOffset; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
78 |
iInputFile = aData.iInputFile; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
79 |
iData = aData.iData; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
80 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
81 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
82 |
ElfSectionFileData * ElfSectionFileData::Clone(){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
83 |
return new ElfSectionFileData(*this); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
84 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
85 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
86 |
void ElfSectionFileData::GetFileFragmentData(FileFragmentData & aFileFragmentData ){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
87 |
iData = iInputFile->GetData(); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
88 |
SetFileFragmentData(aFileFragmentData, iInputFile->Size(), (char *)iData); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
89 |
} |
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 |
void ElfSectionFileData::DeleteFileFragmentData(){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
92 |
if (iData) { |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
93 |
char * d = iData; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
94 |
iData = NULL; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
95 |
delete [] d; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
96 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
97 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
98 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
99 |
size_t ElfSectionFileData::Size(){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
100 |
return iInputFile->Size(); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
101 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
102 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
103 |
ElfSectionNoData::ElfSectionNoData(const ElfSectionNoData & aData) { |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
104 |
iOffset = aData.iOffset; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
105 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
106 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
107 |
ElfSectionNoData * ElfSectionNoData::Clone(){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
108 |
return new ElfSectionNoData(*this); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
109 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
110 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
111 |
void ElfSectionNoData::GetFileFragmentData(FileFragmentData & aFileFragmentData ){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
112 |
SetFileFragmentData(aFileFragmentData, 0u, reinterpret_cast<char *>(NULL)); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
113 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
114 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
115 |
ElfSection::~ElfSection(){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
116 |
delete iSectionData; |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
117 |
} |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
118 |
|
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
119 |
void ElfSection::AddData(OutputFile & aOutputFile){ |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
120 |
iSectionData->AddData(aOutputFile); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
121 |
SetSize(iSectionData->Size()); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
122 |
SetOffset(iSectionData->GetOffset()); |
92d87f2e53c2
Added ELF4ROM and e32test-driver
Martin Trojer <martin.trojer@nokia.com>
parents:
diff
changeset
|
123 |
} |