[LLVMbugs] [Bug 11154] New: findModuleDefiningSymbol & findModuleDefiningSymbols have inconsistent view of symTab

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Oct 17 08:35:40 PDT 2011


http://llvm.org/bugs/show_bug.cgi?id=11154

           Summary: findModuleDefiningSymbol & findModuleDefiningSymbols
                    have inconsistent view of symTab
           Product: tools
           Version: trunk
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: llvm-ld
        AssignedTo: unassignedbugs at nondot.org
        ReportedBy: gmalecha at eecs.harvard.edu
                CC: llvmbugs at cs.uiuc.edu


Created an attachment (id=7469)
 --> (http://llvm.org/bugs/attachment.cgi?id=7469)
patch

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).

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.



More information about the llvm-bugs mailing list