summaryrefslogtreecommitdiffstats
path: root/Source/bindexplib.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/bindexplib.cxx')
-rw-r--r--Source/bindexplib.cxx53
1 files changed, 38 insertions, 15 deletions
diff --git a/Source/bindexplib.cxx b/Source/bindexplib.cxx
index eded883..47c7565 100644
--- a/Source/bindexplib.cxx
+++ b/Source/bindexplib.cxx
@@ -64,7 +64,7 @@
#include "bindexplib.h"
#include <cmsys/Encoding.hxx>
-#include <fstream>
+#include <cmsys/FStream.hxx>
#include <iostream>
#include <windows.h>
@@ -308,7 +308,8 @@ public:
this->DataSymbols.insert(symbol);
} else {
if ( pSymbolTable->Type ||
- !(SectChar & IMAGE_SCN_MEM_READ)) {
+ !(SectChar & IMAGE_SCN_MEM_READ) ||
+ (SectChar & IMAGE_SCN_MEM_EXECUTE)) {
this->Symbols.insert(symbol);
} else {
// printf(" strange symbol: %s \n",symbol.c_str());
@@ -425,24 +426,46 @@ DumpFile(const char* filename,
bool bindexplib::AddObjectFile(const char* filename)
{
- if(!DumpFile(filename, this->Symbols, this->DataSymbols))
- {
- return false;
- }
- return true;
+ return DumpFile(filename, this->Symbols, this->DataSymbols);
+}
+
+bool bindexplib::AddDefinitionFile(const char* filename)
+{
+ cmsys::ifstream infile(filename);
+ if (!infile) {
+ fprintf(stderr, "Couldn't open definition file '%s'\n", filename);
+ return false;
+ }
+ std::string str;
+ while (std::getline(infile, str)) {
+ // skip the LIBRAY and EXPORTS lines (if any)
+ if ((str.compare(0,7,"LIBRARY") == 0) ||
+ (str.compare(0,7,"EXPORTS") == 0)) {
+ continue;
+ }
+ // remove leading tabs & spaces
+ str.erase(0, str.find_first_not_of(" \t"));
+ std::size_t found = str.find(" \t DATA");
+ if (found != std::string::npos) {
+ str.erase (found, std::string::npos);
+ this->DataSymbols.insert(str);
+ } else {
+ this->Symbols.insert(str);
+ }
+ }
+ infile.close();
+ return true;
}
void bindexplib::WriteFile(FILE* file)
{
fprintf(file,"EXPORTS \n");
- for(std::set<std::string>::const_iterator i = this->DataSymbols.begin();
- i!= this->DataSymbols.end(); ++i)
- {
+ for (std::set<std::string>::const_iterator i = this->DataSymbols.begin();
+ i != this->DataSymbols.end(); ++i) {
fprintf(file, "\t%s \t DATA\n", i->c_str());
- }
- for(std::set<std::string>::const_iterator i = this->Symbols.begin();
- i!= this->Symbols.end(); ++i)
- {
+ }
+ for (std::set<std::string>::const_iterator i = this->Symbols.begin();
+ i != this->Symbols.end(); ++i) {
fprintf(file, "\t%s\n", i->c_str());
- }
+ }
}