MCPcopy Create free account
hub / github.com/CloverHackyColor/CloverBootloader / ConvertElf

Function ConvertElf

BaseTools/Source/C/GenFw/ElfConvert.c:166–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

164}
165
166BOOLEAN
167ConvertElf (
168 UINT8 **FileBuffer,
169 UINT32 *FileLength
170 )
171{
172 ELF_FUNCTION_TABLE ElfFunctions;
173 UINT8 EiClass;
174
175 mFileBufferSize = *FileLength;
176 //
177 // Determine ELF type and set function table pointer correctly.
178 //
179 VerboseMsg ("Check Elf Image Header");
180 EiClass = (*FileBuffer)[EI_CLASS];
181 if (EiClass == ELFCLASS32) {
182#ifndef JIEF_DEBUG
183 // Some globals have the same name and that confuses the debugger.
184 // So it's better not to link with Elf32Convert.o when debugging x64
185 if (!InitializeElf32 (*FileBuffer, &ElfFunctions)) {
186 return FALSE;
187 }
188#endif
189 } else if (EiClass == ELFCLASS64) {
190 if (!InitializeElf64 (*FileBuffer, &ElfFunctions)) {
191 return FALSE;
192 }
193 } else {
194 Error (NULL, 0, 3000, "Unsupported", "ELF EI_CLASS not supported.");
195 return FALSE;
196 }
197
198 //
199 // Compute sections new address.
200 //
201 VerboseMsg ("Compute sections new address.");
202 ElfFunctions.ScanSections ();
203
204 //
205 // Write and relocate sections.
206 //
207 VerboseMsg ("Write and relocate sections.");
208 if (!ElfFunctions.WriteSections (SECTION_TEXT)) {
209 return FALSE;
210 }
211 if (!ElfFunctions.WriteSections (SECTION_DATA)) {
212 return FALSE;
213 }
214 if (!ElfFunctions.WriteSections (SECTION_HII)) {
215 return FALSE;
216 }
217
218 //
219 // Translate and write relocations.
220 //
221 VerboseMsg ("Translate and write relocations.");
222 ElfFunctions.WriteRelocations ();
223

Callers 1

GenFw.cFile · 0.85

Calls 5

VerboseMsgFunction · 0.85
InitializeElf32Function · 0.85
InitializeElf64Function · 0.85
ErrorFunction · 0.50
freeFunction · 0.50

Tested by

no test coverage detected