bindexplib: fix constants symbols export

This commit is contained in:
Mikhail Paulyshka 2017-04-26 00:37:37 +03:00
parent 959ad1d5e8
commit afb21342ea
3 changed files with 25 additions and 19 deletions

View File

@ -235,35 +235,29 @@ public:
symbol.erase(posAt);
}
}
// For i386 builds we don't need to remove _
// For i386 builds we need to remove _
if (this->IsI386 && symbol[0] == '_') {
symbol.erase(0, 1);
}
/*
Check whether it is "Scalar deleting destructor" and
"Vector deleting destructor"
*/
// Check whether it is "Scalar deleting destructor" and "Vector
// deleting destructor"
// if scalarPrefix and vectorPrefix are not found then print the
// symbol
const char* scalarPrefix = "??_G";
const char* vectorPrefix = "??_E";
// original code had a check for
// symbol.find("real@") == std::string::npos)
// but if this disallows memmber functions with the name real
// if scalarPrefix and vectorPrefix are not found then print
// the symbol
if (symbol.compare(0, 4, scalarPrefix) &&
symbol.compare(0, 4, vectorPrefix)) {
SectChar = this->SectionHeaders[pSymbolTable->SectionNumber - 1]
.Characteristics;
if (!pSymbolTable->Type && (SectChar & IMAGE_SCN_MEM_WRITE)) {
// Read only (i.e. constants) must be excluded
this->DataSymbols.insert(symbol);
} else {
if (pSymbolTable->Type || !(SectChar & IMAGE_SCN_MEM_READ) ||
(SectChar & IMAGE_SCN_MEM_EXECUTE)) {
this->Symbols.insert(symbol);
} else {
// printf(" strange symbol: %s \n",symbol.c_str());
if (SectChar & IMAGE_SCN_MEM_EXECUTE) {
this->Symbols.insert(symbol);
} else if (SectChar & IMAGE_SCN_MEM_READ) {
// skip __real@ and __xmm@
if (symbol.find("_real") == std::string::npos &&
symbol.find("_xmm") == std::string::npos) {
this->DataSymbols.insert(symbol);
}
}
}

View File

@ -13,3 +13,5 @@ int bar()
{
return 5;
}
const char testconst[] = "testconst";

View File

@ -13,6 +13,14 @@ int WINAPI foo();
int bar();
int objlib();
void justnop();
// test const export
#ifdef _WIN32
// data symbols must be explicitly imported
__declspec(dllimport) extern const char testconst[];
#else
extern const char testconst[];
#endif
}
// test c++ functions
@ -43,6 +51,8 @@ int main()
bar();
objlib();
printf("\n");
printf("%s", testconst);
printf("\n");
#ifdef HAS_JUSTNOP
justnop();
#endif