diff options
author | Jacek Blaszczynski <biosciencenow@outlook.com> | 2017-12-18 15:15:58 (GMT) |
---|---|---|
committer | Jacek Blaszczynski <biosciencenow@outlook.com> | 2017-12-18 15:15:58 (GMT) |
commit | 14ebad533dd278137e5a4768768217ca95c4ca24 (patch) | |
tree | e8755977356a2b97e2833439d6682489a129d6f7 /Source/bindexplib.cxx | |
parent | 8950183b3834dc2179dc4965138b1091e291ae9f (diff) | |
download | CMake-14ebad533dd278137e5a4768768217ca95c4ca24.zip CMake-14ebad533dd278137e5a4768768217ca95c4ca24.tar.gz CMake-14ebad533dd278137e5a4768768217ca95c4ca24.tar.bz2 |
Use IMAGE_FILE_HEADER and add missing Arm 32bit images support
Diffstat (limited to 'Source/bindexplib.cxx')
-rw-r--r-- | Source/bindexplib.cxx | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/Source/bindexplib.cxx b/Source/bindexplib.cxx index 698ab78..21f27d6 100644 --- a/Source/bindexplib.cxx +++ b/Source/bindexplib.cxx @@ -31,7 +31,7 @@ * Extension (Axel 2006-03-15) * As soon as an object file contains an /EXPORT directive (which * is generated by the compiler when a symbol is declared as - * declspec(dllexport)) no to-be-exported symbols are printed, + * __declspec(dllexport) no to-be-exported symbols are printed, * as the linker will see these directives, and if those directives * are present we only export selectively (i.e. we trust the * programmer). @@ -50,12 +50,12 @@ * * It created a wrong EXPORTS for the global pointers and constants. * The Section Header has been involved to discover the missing information -* Now the pointers are correctly supplied supplied with "DATA" descriptor +* Now the pointers are correctly supplied with "DATA" descriptor * the constants with no extra descriptor. * * Corrections (Valery Fine 16/09/96): * -* It didn't work for C++ code with global variables and class definitons +* It didn't work for C++ code with global variables and class definitions * The DumpExternalObject function has been introduced to generate .DEF file * * Author: Valery Fine 16/09/96 (E-mail: fine@vxcern.cern.ch) @@ -68,8 +68,20 @@ #include <iostream> #include <windows.h> +#ifndef IMAGE_FILE_MACHINE_ARM +#define IMAGE_FILE_MACHINE_ARM 0x01c0 // ARM Little-Endian +#endif + +#ifndef IMAGE_FILE_MACHINE_THUMB +#define IMAGE_FILE_MACHINE_THUMB 0x01c2 // ARM Thumb/Thumb-2 Little-Endian +#endif + #ifndef IMAGE_FILE_MACHINE_ARMNT -#define IMAGE_FILE_MACHINE_ARMNT 0x01c4 +#define IMAGE_FILE_MACHINE_ARMNT 0x01c4 // ARM Thumb-2 Little-Endian +#endif + +#ifndef IMAGE_FILE_MACHINE_ARM64 +#define IMAGE_FILE_MACHINE_ARM64 0xaa64 // ARM64 Little-Endian #endif typedef struct cmANON_OBJECT_HEADER_BIGOBJ @@ -294,7 +306,6 @@ bool DumpFile(const char* filename, std::set<std::string>& symbols, HANDLE hFile; HANDLE hFileMapping; LPVOID lpFileBase; - PIMAGE_DOS_HEADER dosHeader; hFile = CreateFileW(cmsys::Encoding::ToWide(filename).c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, @@ -320,17 +331,18 @@ bool DumpFile(const char* filename, std::set<std::string>& symbols, return false; } - dosHeader = (PIMAGE_DOS_HEADER)lpFileBase; - if (dosHeader->e_magic == IMAGE_DOS_SIGNATURE) { + const PIMAGE_FILE_HEADER imageHeader = (PIMAGE_FILE_HEADER)lpFileBase; + if (imageHeader->Machine == 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 (((dosHeader->e_magic == IMAGE_FILE_MACHINE_I386) || - (dosHeader->e_magic == IMAGE_FILE_MACHINE_AMD64) || - (dosHeader->e_magic == IMAGE_FILE_MACHINE_ARMNT)) || - (dosHeader->e_magic == IMAGE_FILE_MACHINE_ARM64) && - (dosHeader->e_sp == 0)) { + 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) @@ -338,7 +350,7 @@ bool DumpFile(const char* filename, std::set<std::string>& symbols, */ DumpSymbols<IMAGE_FILE_HEADER, IMAGE_SYMBOL> symbolDumper( (PIMAGE_FILE_HEADER)lpFileBase, symbols, dataSymbols, - (dosHeader->e_magic == IMAGE_FILE_MACHINE_I386)); + (imageHeader->Machine == IMAGE_FILE_MACHINE_I386)); symbolDumper.DumpObjFile(); } else { // check for /bigobj format |