From ad510831cafa07d45d973e5fc941c62b9d8946f9 Mon Sep 17 00:00:00 2001 From: Rainer Schuetze Date: Wed, 12 Dec 2018 08:37:42 +0100 Subject: fix #40: set architecture of .pdb for a 64 bit .dbg --- src/PEImage.cpp | 4 ++++ src/PEImage.h | 15 ++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/PEImage.cpp b/src/PEImage.cpp index 644f36e..d3651c8 100644 --- a/src/PEImage.cpp +++ b/src/PEImage.cpp @@ -54,6 +54,7 @@ PEImage::PEImage(const TCHAR* iname) , strtable(0) , bigobj(false) , dbgfile(false) +, x64(false) { if(iname) loadExe(iname); @@ -266,6 +267,7 @@ bool PEImage::initCVPtr(bool initDbgDir) hdr32 = 0; else hdr64 = 0; + x64 = hdr64 != nullptr; if(IMGHDR(Signature) != IMAGE_NT_SIGNATURE) return setError("optional header does not have PE signature"); @@ -324,6 +326,7 @@ bool PEImage::initDbgPtr(bool initDbgDir) if(dbg->DebugDirectorySize <= IMAGE_DIRECTORY_ENTRY_DEBUG) return setError("too few entries in data directory"); + x64 = dbg->Machine == IMAGE_FILE_MACHINE_AMD64 || dbg->Machine == IMAGE_FILE_MACHINE_IA64; dbgfile = true; dbgDir = 0; dirHeader = 0; @@ -389,6 +392,7 @@ bool PEImage::initDWARFPtr(bool initDbgDir) hdr32 = 0; else hdr64 = 0; + x64 = hdr64 != nullptr; if(IMGHDR(Signature) != IMAGE_NT_SIGNATURE) return setError("optional header does not have PE signature"); diff --git a/src/PEImage.h b/src/PEImage.h index 6ebd131..2935419 100644 --- a/src/PEImage.h +++ b/src/PEImage.h @@ -70,7 +70,7 @@ public: bool relocateDebugLineInfo(unsigned int img_base); bool hasDWARF() const { return debug_line != 0; } - bool isX64() const { return hdr64 != 0; } + bool isX64() const { return x64; } bool isDBG() const { return dbgfile; } int countCVEntries() const; @@ -111,12 +111,13 @@ private: IMAGE_DEBUG_DIRECTORY* dbgDir; OMFDirHeader* dirHeader; OMFDirEntry* dirEntry; - int nsec; - int nsym; - const char* symtable; - const char* strtable; - bool bigobj; - bool dbgfile; // is DBG file + int nsec; + int nsym; + const char* symtable; + const char* strtable; + bool x64; // targets 64-bit machine + bool bigobj; + bool dbgfile; // is DBG file public: //dwarf -- cgit v0.12