diff options
author | Jacek Blaszczynski <biosciencenow@outlook.com> | 2017-12-18 17:22:50 (GMT) |
---|---|---|
committer | Jacek Blaszczynski <biosciencenow@outlook.com> | 2017-12-18 17:26:55 (GMT) |
commit | 1f3933d3825e6e99cc60065a8666c5e22bb1e7c2 (patch) | |
tree | 02df03170eb8596025c8d2c56831c00f6c03e6c3 /Source/bindexplib.cxx | |
parent | 14ebad533dd278137e5a4768768217ca95c4ca24 (diff) | |
download | CMake-1f3933d3825e6e99cc60065a8666c5e22bb1e7c2.zip CMake-1f3933d3825e6e99cc60065a8666c5e22bb1e7c2.tar.gz CMake-1f3933d3825e6e99cc60065a8666c5e22bb1e7c2.tar.bz2 |
Address code review feedback
Diffstat (limited to 'Source/bindexplib.cxx')
-rw-r--r-- | Source/bindexplib.cxx | 58 |
1 files changed, 31 insertions, 27 deletions
diff --git a/Source/bindexplib.cxx b/Source/bindexplib.cxx index 21f27d6..9ec9624 100644 --- a/Source/bindexplib.cxx +++ b/Source/bindexplib.cxx @@ -331,38 +331,42 @@ bool DumpFile(const char* filename, std::set<std::string>& symbols, return false; } - const PIMAGE_FILE_HEADER imageHeader = (PIMAGE_FILE_HEADER)lpFileBase; - if (imageHeader->Machine == IMAGE_DOS_SIGNATURE) { + const PIMAGE_DOS_HEADER dosHeader = (PIMAGE_DOS_HEADER)lpFileBase; + if (dosHeader->e_magic == IMAGE_DOS_SIGNATURE) { fprintf(stderr, "File is an executable. I don't dump those.\n"); return false; - } - /* Does it look like a COFF OBJ file??? */ - else if (((imageHeader->Machine == IMAGE_FILE_MACHINE_I386) || - (imageHeader->Machine == IMAGE_FILE_MACHINE_AMD64) || - (imageHeader->Machine == IMAGE_FILE_MACHINE_ARM) || - (imageHeader->Machine == IMAGE_FILE_MACHINE_ARMNT) || - (imageHeader->Machine == IMAGE_FILE_MACHINE_ARM64)) && - (imageHeader->Characteristics == 0)) { - /* - * The two tests above aren't what they look like. They're - * really checking for IMAGE_FILE_HEADER.Machine == i386 (0x14C) - * and IMAGE_FILE_HEADER.SizeOfOptionalHeader == 0; - */ - DumpSymbols<IMAGE_FILE_HEADER, IMAGE_SYMBOL> symbolDumper( - (PIMAGE_FILE_HEADER)lpFileBase, symbols, dataSymbols, - (imageHeader->Machine == IMAGE_FILE_MACHINE_I386)); - symbolDumper.DumpObjFile(); } else { - // check for /bigobj format - cmANON_OBJECT_HEADER_BIGOBJ* h = (cmANON_OBJECT_HEADER_BIGOBJ*)lpFileBase; - if (h->Sig1 == 0x0 && h->Sig2 == 0xffff) { - DumpSymbols<cmANON_OBJECT_HEADER_BIGOBJ, cmIMAGE_SYMBOL_EX> symbolDumper( - (cmANON_OBJECT_HEADER_BIGOBJ*)lpFileBase, symbols, dataSymbols, - (h->Machine == IMAGE_FILE_MACHINE_I386)); + const PIMAGE_FILE_HEADER imageHeader = (PIMAGE_FILE_HEADER)lpFileBase; + /* Does it look like a COFF OBJ file??? */ + if (((imageHeader->Machine == IMAGE_FILE_MACHINE_I386) || + (imageHeader->Machine == IMAGE_FILE_MACHINE_AMD64) || + (imageHeader->Machine == IMAGE_FILE_MACHINE_ARM) || + (imageHeader->Machine == IMAGE_FILE_MACHINE_ARMNT) || + (imageHeader->Machine == IMAGE_FILE_MACHINE_ARM64)) && + (imageHeader->Characteristics == 0)) { + /* + * The tests above are checking for IMAGE_FILE_HEADER.Machine + * if it contains supported machine formats (currently ARM and x86) + * and IMAGE_FILE_HEADER.Characteristics == 0 indicating that + * this is not linked COFF OBJ file; + */ + DumpSymbols<IMAGE_FILE_HEADER, IMAGE_SYMBOL> symbolDumper( + (PIMAGE_FILE_HEADER)lpFileBase, symbols, dataSymbols, + (imageHeader->Machine == IMAGE_FILE_MACHINE_I386)); symbolDumper.DumpObjFile(); } else { - printf("unrecognized file format in '%s'\n", filename); - return false; + // check for /bigobj format + cmANON_OBJECT_HEADER_BIGOBJ* h = + (cmANON_OBJECT_HEADER_BIGOBJ*)lpFileBase; + if (h->Sig1 == 0x0 && h->Sig2 == 0xffff) { + DumpSymbols<cmANON_OBJECT_HEADER_BIGOBJ, cmIMAGE_SYMBOL_EX> + symbolDumper((cmANON_OBJECT_HEADER_BIGOBJ*)lpFileBase, symbols, + dataSymbols, (h->Machine == IMAGE_FILE_MACHINE_I386)); + symbolDumper.DumpObjFile(); + } else { + printf("unrecognized file format in '%s'\n", filename); + return false; + } } } UnmapViewOfFile(lpFileBase); |