[llvm-bugs] [Bug 41828] New: lld-link /safeseh:no doesn't prevent writing of __safe_se_handler_table

via llvm-bugs llvm-bugs at lists.llvm.org
Fri May 10 05:27:36 PDT 2019


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

            Bug ID: 41828
           Summary: lld-link /safeseh:no doesn't prevent writing of
                    __safe_se_handler_table
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: COFF
          Assignee: unassignedbugs at nondot.org
          Reporter: nicolasweber at gmx.de
                CC: llvm-bugs at lists.llvm.org

https://resemblances.click3.org/?p=1969 says that lld-link ignores /safeseh:no

Indeed this seems to be the case. Driver.cpp:

  // Handle /safeseh.
  if (Args.hasFlag(OPT_safeseh, OPT_safeseh_no, false)) {
    for (ObjFile *File : ObjFile::Instances)
      if (!File->hasSafeSEH())
        error("/safeseh: " + File->getName() + " is not compatible with SEH");
    if (errorCount())
      return;
  }



Writer.cpp:

void Writer::createSEHTable() {
  // Set the no SEH characteristic on x86 binaries unless we find exception
  // handlers.
  SetNoSEHCharacteristic = true;

  SymbolRVASet Handlers;
  for (ObjFile *File : ObjFile::Instances) {
    // FIXME: We should error here instead of earlier unless /safeseh:no was
    // passed.
    if (!File->hasSafeSEH())
      return;

    markSymbolsForRVATable(File, File->getSXDataChunks(), Handlers);
  }

  // Remove the "no SEH" characteristic if all object files were built with
  // safeseh, we found some exception handlers, and there is a load config in
  // the object.
  SetNoSEHCharacteristic =
      Handlers.empty() || !Symtab->findUnderscore("_load_config_used");

  maybeAddRVATable(std::move(Handlers), "__safe_se_handler_table",
                   "__safe_se_handler_count");
}




We should probably make /safeseh:no set some config flag to false and then read
this in Writer.


Or is it intentional that this can't be disabled with lld?

-- 
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/20190510/754fd0b4/attachment.html>


More information about the llvm-bugs mailing list