[llvm-bugs] [Bug 27704] New: Exception ( zero dividing) during code generation on windows plataform - RuntimeDyld.cpp

via llvm-bugs llvm-bugs at lists.llvm.org
Tue May 10 13:44:06 PDT 2016


https://llvm.org/bugs/show_bug.cgi?id=27704

            Bug ID: 27704
           Summary: Exception ( zero dividing) during code generation on
                    windows plataform - RuntimeDyld.cpp
           Product: compiler-rt
           Version: unspecified
          Hardware: PC
                OS: Windows 2000
            Status: NEW
          Severity: normal
          Priority: P
         Component: compiler-rt
          Assignee: unassignedbugs at nondot.org
          Reporter: mbsteixeira at gmail.com
                CC: llvm-bugs at lists.llvm.org
    Classification: Unclassified

This problem occurs on the trunk sources.

During code generation there is a exception  in the file RuntimeDyld.cpp.
Present code :
Error RuntimeDyldImpl::emitCommonSymbols(const ObjectFile &Obj,
                                         CommonSymbolList &CommonSymbols) {
  if (CommonSymbols.empty())
    return Error::success();

  uint64_t CommonSize = 0;
  uint32_t CommonAlign = CommonSymbols.begin()->getAlignment();
  CommonSymbolList SymbolsToAllocate;

  DEBUG(dbgs() << "Processing common symbols...\n");

  for (const auto &Sym : CommonSymbols) {
    StringRef Name;
    if (auto NameOrErr = Sym.getName())
      Name = *NameOrErr;
    else
      return NameOrErr.takeError();

    // Skip common symbols already elsewhere.
    if (GlobalSymbolTable.count(Name) ||
        Resolver.findSymbolInLogicalDylib(Name)) {
      DEBUG(dbgs() << "\tSkipping already emitted common symbol '" << Name
                   << "'\n");
      continue;
    }

    uint32_t Align = Sym.getAlignment();  <== here return 0
    uint64_t Size = Sym.getCommonSize();

    CommonSize = alignTo(CommonSize, Align) + Size;  <== here there is a zero
divide exception

    SymbolsToAllocate.push_back(Sym);
  }

The old code was :
void RuntimeDyldImpl::emitCommonSymbols(const ObjectFile &Obj,
                                        CommonSymbolList &CommonSymbols) {
  if (CommonSymbols.empty())
    return;

  uint64_t CommonSize = 0;
  CommonSymbolList SymbolsToAllocate;

  DEBUG(dbgs() << "Processing common symbols...\n");

  for (const auto &Sym : CommonSymbols) {
    ErrorOr<StringRef> NameOrErr = Sym.getName();
    Check(NameOrErr.getError());
    StringRef Name = *NameOrErr;

    // Skip common symbols already elsewhere.
    if (GlobalSymbolTable.count(Name) ||
        Resolver.findSymbolInLogicalDylib(Name)) {
      DEBUG(dbgs() << "\tSkipping already emitted common symbol '" << Name
                   << "'\n");
      continue;
    }

    uint32_t Align = Sym.getAlignment();
    uint64_t Size = Sym.getCommonSize();

    CommonSize += Align + Size;
    SymbolsToAllocate.push_back(Sym);
  }

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20160510/c748777f/attachment.html>


More information about the llvm-bugs mailing list