Skip to content
This repository has been archived by the owner on Mar 18, 2020. It is now read-only.

Commit

Permalink
check global records for linkage type
Browse files Browse the repository at this point in the history
  • Loading branch information
luser committed Sep 21, 2014
1 parent b260f6c commit 71add3e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
17 changes: 14 additions & 3 deletions PDBParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ PDBParser::FunctionRecord& PDBParser::FunctionRecord::operator =(FunctionRecord&
std::swap(lineOffset, other.lineOffset);
std::swap(typeIndex, other.typeIndex);
std::swap(paramSize, other.paramSize);
std::swap(isExternC, other.isExternC);

return *this;
}
Expand Down Expand Up @@ -835,6 +836,12 @@ PDBParser::printBreakpadSymbols(FILE* of, const char* platform, FileMod* fileMod
updateParamSize(func, globals);
}
}
// While here, see if this function uses C linkage
auto& g = globals.find(func.offset);
if (g != globals.end() && g->second.data[0] != '?')
{
func.isExternC = true;
}
}

// Wait for the type stream to be loaded, and all of the src files to be written
Expand Down Expand Up @@ -1050,10 +1057,13 @@ PDBParser::getGlobalFunctions(uint16_t symRecStream, const SectionHeaders& heade
{
auto len = *reader.read<uint16_t>().data;
auto rec = reader.read<GlobalRecord>();
auto name = reader.read<char>(len - sizeof(GlobalRecord));
if (rec->leafType == 0x1009)
throw std::exception("Global data_v2 records not handled!");

auto name = reader.read<char>(len - sizeof(GlobalRecord));
fprintf(stderr, "%x %s %d %d\n", rec->offset, name.data, rec->leafType, rec->segment);
// Is function?
if (rec->symType == 2)
if (rec->leafType == 0x110e && rec->symType == 2)
{
globals.insert(std::make_pair(rec->offset + headers[rec->segment - 1].VirtualAddress, std::move(name)));
}
Expand Down Expand Up @@ -1123,7 +1133,8 @@ PDBParser::printFunctions(Functions& funcs, const TypeMap& tm, FILE* of)

if (func.typeIndex)
{
stringizeType(func.typeIndex, str, tm, IsTopLevel);
if (!func.isExternC)
stringizeType(func.typeIndex, str, tm, IsTopLevel);

temp.assign(func.name.data);
std::string::size_type pos;
Expand Down
2 changes: 2 additions & 0 deletions PDBParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class PDBParser
uint32_t lineOffset;
uint32_t typeIndex; // If this is non-zero, the function is a procedure, not a thunk (I don't know how to read thunk type info...)
uint32_t paramSize;
bool isExternC;

FunctionRecord(uint32_t offset, uint32_t segment)
: offset(offset)
Expand All @@ -158,6 +159,7 @@ class PDBParser
, lineOffset(0)
, fileIndex(0)
, paramSize(0)
, isExternC(false)
{}

bool operator <(const FunctionRecord& other) const
Expand Down

0 comments on commit 71add3e

Please sign in to comment.