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