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

Method LoadDynamicSection

Source/cmELF.cxx:469–505  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

467
468template <class Types>
469bool cmELFInternalImpl<Types>::LoadDynamicSection()
470{
471 // If there is no dynamic section we are done.
472 if (!this->HasDynamicSection()) {
473 return false;
474 }
475
476 // If the section was already loaded we are done.
477 if (!this->DynamicSectionEntries.empty()) {
478 return true;
479 }
480
481 // If there are no entries we are done.
482 ELF_Shdr const& sec = this->SectionHeaders[this->DynamicSectionIndex];
483 if (sec.sh_entsize == 0) {
484 return false;
485 }
486
487 // Allocate the dynamic section entries.
488 int n = static_cast<int>(sec.sh_size / sec.sh_entsize);
489 this->DynamicSectionEntries.resize(n);
490
491 // Read each entry.
492 for (int j = 0; j < n; ++j) {
493 // Seek to the beginning of the section entry.
494 this->Stream->seekg(sec.sh_offset + sec.sh_entsize * j);
495 ELF_Dyn& dyn = this->DynamicSectionEntries[j];
496
497 // Try reading the entry.
498 if (!this->Read(dyn)) {
499 this->SetErrorMessage("Error reading entry from DYNAMIC section.");
500 this->DynamicSectionIndex = -1;
501 return false;
502 }
503 }
504 return true;
505}
506
507template <class Types>
508unsigned long cmELFInternalImpl<Types>::GetDynamicEntryPosition(int j)

Callers 3

GetDynamicEntriesMethod · 0.95

Calls 5

ReadMethod · 0.95
HasDynamicSectionMethod · 0.45
emptyMethod · 0.45
resizeMethod · 0.45
SetErrorMessageMethod · 0.45

Tested by

no test coverage detected