summaryrefslogtreecommitdiffstats
path: root/src/PEImage.cpp
diff options
context:
space:
mode:
authorRainer Schuetze <r.sagitario@gmx.de>2015-06-03 05:15:03 (GMT)
committerRainer Schuetze <r.sagitario@gmx.de>2015-06-03 05:15:03 (GMT)
commit10e34a2a218b1af3d8f5a84ff3e1d44b48364d20 (patch)
tree1b524a935a5614433a3b645096b1c782aebd4981 /src/PEImage.cpp
parent750dcfdf2dcd38cad1bfead1a74a91f769b44a97 (diff)
downloadcv2pdb-10e34a2a218b1af3d8f5a84ff3e1d44b48364d20.zip
cv2pdb-10e34a2a218b1af3d8f5a84ff3e1d44b48364d20.tar.gz
cv2pdb-10e34a2a218b1af3d8f5a84ff3e1d44b48364d20.tar.bz2
remove DWARF sections from executable
Diffstat (limited to 'src/PEImage.cpp')
-rw-r--r--src/PEImage.cpp25
1 files changed, 22 insertions, 3 deletions
diff --git a/src/PEImage.cpp b/src/PEImage.cpp
index 707cc7e..ed663a2 100644
--- a/src/PEImage.cpp
+++ b/src/PEImage.cpp
@@ -146,10 +146,22 @@ bool PEImage::replaceDebugSection (const void* data, int datalen, bool initCV)
// assume there is place for another section because of section alignment
int s;
DWORD lastVirtualAddress = 0;
+ int firstDWARFsection = -1;
int cntSections = countSections();
for(s = 0; s < cntSections; s++)
{
- if (strcmp ((char*) sec [s].Name, ".debug") == 0)
+ const char* name = (const char*) sec[s].Name;
+ if(name[0] == '/')
+ {
+ int off = strtol(name + 1, 0, 10);
+ name = strtable + off;
+ }
+ if (strncmp (name, ".debug_", 7) != 0)
+ firstDWARFsection = -1;
+ else if (firstDWARFsection < 0)
+ firstDWARFsection = s;
+
+ if (strcmp (name, ".debug") == 0)
{
if (s == cntSections - 1)
{
@@ -159,9 +171,14 @@ bool PEImage::replaceDebugSection (const void* data, int datalen, bool initCV)
strcpy ((char*) sec [s].Name, ".ddebug");
printf("warning: .debug not last section, cannot remove section\n");
}
- lastVirtualAddress = sec [s].VirtualAddress + sec[s].Misc.VirtualSize;
+ lastVirtualAddress = sec[s].VirtualAddress + sec[s].Misc.VirtualSize;
}
-
+ if (firstDWARFsection > 0)
+ {
+ s = firstDWARFsection;
+ dump_total_len = sec[s].PointerToRawData;
+ lastVirtualAddress = sec[s-1].VirtualAddress + sec[s-1].Misc.VirtualSize;
+ }
int align = IMGHDR(OptionalHeader.FileAlignment);
int align_len = xdatalen;
int fill = 0;
@@ -373,6 +390,8 @@ bool PEImage::initDWARFObject()
static DWORD sizeInImage(const IMAGE_SECTION_HEADER& sec)
{
+ if (sec.Misc.VirtualSize == 0)
+ return sec.SizeOfRawData; // for object files
return sec.SizeOfRawData < sec.Misc.VirtualSize ? sec.SizeOfRawData : sec.Misc.VirtualSize;
}