From 48fa291469e5e8b3ae88fb846750df72468eb58a Mon Sep 17 00:00:00 2001 From: Mikhail Paulyshka Date: Wed, 22 Mar 2017 17:57:02 +0300 Subject: bindexplib: add ARM support Fixes: #16728 --- Source/bindexplib.cxx | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/Source/bindexplib.cxx b/Source/bindexplib.cxx index 4839ec8..75a2177 100644 --- a/Source/bindexplib.cxx +++ b/Source/bindexplib.cxx @@ -68,6 +68,10 @@ #include #include +#ifndef IMAGE_FILE_MACHINE_ARMNT +#define IMAGE_FILE_MACHINE_ARMNT 0x01c4 +#endif + typedef struct cmANON_OBJECT_HEADER_BIGOBJ { /* same as ANON_OBJECT_HEADER_V2 */ @@ -166,7 +170,7 @@ public: */ DumpSymbols(ObjectHeaderType* ih, std::set& symbols, - std::set& dataSymbols, bool is64) + std::set& dataSymbols, bool isI386) : Symbols(symbols) , DataSymbols(dataSymbols) { @@ -176,7 +180,7 @@ public: this->ObjectImageHeader->PointerToSymbolTable); this->SectionHeaders = GetSectionHeaderOffset(this->ObjectImageHeader); this->SymbolCount = this->ObjectImageHeader->NumberOfSymbols; - this->Is64Bit = is64; + this->IsI386 = isI386; } /* @@ -231,12 +235,11 @@ public: symbol.erase(posAt); } } - // For 64 bit builds we don't need to remove _ - if (!this->Is64Bit) { - if (symbol[0] == '_') { - symbol.erase(0, 1); - } + // For i386 builds we don't need to remove _ + if (this->IsI386 && symbol[0] == '_') { + symbol.erase(0, 1); } + /* Check whether it is "Scalar deleting destructor" and "Vector deleting destructor" @@ -283,7 +286,7 @@ private: PIMAGE_SECTION_HEADER SectionHeaders; ObjectHeaderType* ObjectImageHeader; SymbolTableType* SymbolTable; - bool Is64Bit; + bool IsI386; }; bool DumpFile(const char* filename, std::set& symbols, @@ -323,9 +326,10 @@ bool DumpFile(const char* filename, std::set& symbols, fprintf(stderr, "File is an executable. I don't dump those.\n"); return false; } - /* Does it look like a i386 COFF OBJ file??? */ + /* 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_AMD64) || + (dosHeader->e_magic == IMAGE_FILE_MACHINE_ARMNT)) && (dosHeader->e_sp == 0)) { /* * The two tests above aren't what they look like. They're @@ -334,7 +338,7 @@ bool DumpFile(const char* filename, std::set& symbols, */ DumpSymbols symbolDumper( (PIMAGE_FILE_HEADER)lpFileBase, symbols, dataSymbols, - (dosHeader->e_magic == IMAGE_FILE_MACHINE_AMD64)); + (dosHeader->e_magic == IMAGE_FILE_MACHINE_I386)); symbolDumper.DumpObjFile(); } else { // check for /bigobj format @@ -342,7 +346,7 @@ bool DumpFile(const char* filename, std::set& symbols, if (h->Sig1 == 0x0 && h->Sig2 == 0xffff) { DumpSymbols symbolDumper( (cmANON_OBJECT_HEADER_BIGOBJ*)lpFileBase, symbols, dataSymbols, - (h->Machine == IMAGE_FILE_MACHINE_AMD64)); + (h->Machine == IMAGE_FILE_MACHINE_I386)); symbolDumper.DumpObjFile(); } else { printf("unrecognized file format in '%s'\n", filename); -- cgit v0.12