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

Method Read

Source/cmELF.cxx:327–357  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

325 }
326
327 bool Read(ELF_Ehdr& x)
328 {
329 // Read the header from the file.
330 if (!this->Stream->read(reinterpret_cast<char*>(&x), sizeof(x))) {
331 return false;
332 }
333
334 // The byte order of ELF header fields may not match that of the
335 // processor-specific data. The header fields are ordered to
336 // match the target execution environment, so we may need to
337 // memorize the order of all platforms based on the e_machine
338 // value. As a heuristic, if the type is invalid but its
339 // swapped value is okay then flip our swap mode.
340 ELF_Half et = x.e_type;
341 if (this->NeedSwap) {
342 cmELFByteSwap(et);
343 }
344 if (!this->FileTypeValid(et)) {
345 cmELFByteSwap(et);
346 if (this->FileTypeValid(et)) {
347 // The previous byte order guess was wrong. Flip it.
348 this->NeedSwap = !this->NeedSwap;
349 }
350 }
351
352 // Fix the byte order of the header.
353 if (this->NeedSwap) {
354 this->ByteSwap(x);
355 }
356 return true;
357 }
358 bool Read(ELF_Shdr& x)
359 {
360 if (this->Stream->read(reinterpret_cast<char*>(&x), sizeof(x)) &&

Callers 3

LoadSectionHeaderMethod · 0.95
cmELFInternalImplMethod · 0.95
LoadDynamicSectionMethod · 0.95

Calls 4

FileTypeValidMethod · 0.95
ByteSwapMethod · 0.95
cmELFByteSwapFunction · 0.85
readMethod · 0.45

Tested by

no test coverage detected