MCPcopy Create free account
hub / github.com/Kitware/CMake / cmELFInternalImpl

Method cmELFInternalImpl

Source/cmELF.cxx:405–466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

403
404template <class Types>
405cmELFInternalImpl<Types>::cmELFInternalImpl(cmELF* external,
406 std::unique_ptr<std::istream> fin,
407 ByteOrderType order)
408 : cmELFInternal(external, std::move(fin), order)
409{
410 // Read the main header.
411 if (!this->Read(this->ELFHeader)) {
412 this->SetErrorMessage("Failed to read main ELF header.");
413 return;
414 }
415
416 // Determine the ELF file type.
417 switch (this->ELFHeader.e_type) {
418 case ET_NONE:
419 this->SetErrorMessage("ELF file type is NONE.");
420 return;
421 case ET_REL:
422 this->ELFType = cmELF::FileTypeRelocatableObject;
423 break;
424 case ET_EXEC:
425 this->ELFType = cmELF::FileTypeExecutable;
426 break;
427 case ET_DYN:
428 this->ELFType = cmELF::FileTypeSharedLibrary;
429 break;
430 case ET_CORE:
431 this->ELFType = cmELF::FileTypeCore;
432 break;
433 default: {
434 unsigned int eti = static_cast<unsigned int>(this->ELFHeader.e_type);
435 if (eti >= ET_LOOS && eti <= ET_HIOS) {
436 this->ELFType = cmELF::FileTypeSpecificOS;
437 break;
438 }
439 if (eti >= ET_LOPROC && eti <= ET_HIPROC) {
440 this->ELFType = cmELF::FileTypeSpecificProc;
441 break;
442 }
443 std::ostringstream e;
444 e << "Unknown ELF file type " << eti;
445 this->SetErrorMessage(e.str().c_str());
446 return;
447 }
448 }
449
450 this->Machine = this->ELFHeader.e_machine;
451
452 // Load the section headers.
453 std::size_t const minSections = 1;
454 std::size_t numSections = this->ELFHeader.e_shnum;
455 this->SectionHeaders.resize(std::max(numSections, minSections));
456 if (!this->LoadSectionHeader(0)) {
457 return;
458 }
459 numSections = this->GetNumberOfSections();
460 this->SectionHeaders.resize(std::max(numSections, minSections));
461 for (std::size_t i = 1; i < numSections; ++i) {
462 if (!this->LoadSectionHeader(i)) {

Callers

nothing calls this directly

Calls 8

ReadMethod · 0.95
LoadSectionHeaderMethod · 0.95
GetNumberOfSectionsMethod · 0.95
moveFunction · 0.85
c_strMethod · 0.80
strMethod · 0.80
SetErrorMessageMethod · 0.45
resizeMethod · 0.45

Tested by

no test coverage detected