Skip to content

findModuleDefiningSymbol & findModuleDefiningSymbols have inconsistent view of symTab #11526

@llvmbot

Description

@llvmbot
Bugzilla Link 11154
Version trunk
OS Linux
Attachments patch
Reporter LLVM Bugzilla Contributor
CC @efriedma-quic

Extended Description

It seems that the two functions Achive::findModuleDefiningSymbol and Archive::findModulesDefiningSymbols are inconsistent in their use of the index of the modules map. Code snippets:

Archive::findModulesDefiningSymbols (line 510)
const char* At = base + firstFileOffset;
...
unsigned offset = At - base - firstFileOffset;
...
symTab.insert(std::make_pair(*I, offset)); // *I is the symbol
modules.insert(std::make_pair(offset, std::make_pair(M, mbr)));

Archive::findModuleDefininingSymbol (line 460)
SymTabType::iterator SI = symTab.find(symbol);
...
unsigned fileOffset =
SI->second + // offset in symbol-table-less file
firstFileOffset; // add offset to first "real" file in archive
...
ModuleMap::iterator MI = modules.find(fileOffset);

In findModuleDefiningSymbol, firstFileOffset is added in before looking up into the map, while the offset associated with a symbol has this value subtracted out. In most cases this just causes a cache miss, so the module would be loaded but in some rare instances the offset points to a valid module which causes us to look at the wrong module.

I think the appropriate fix is to fix the population of the modules map inside findModulesDefiningSymbols (patch attached).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillallvm-toolsAll llvm tools that do not have corresponding tag

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions