[llvm-bugs] [Bug 35337] New: LLD ICF needs to consider exception tables in .xdata as part of .text equivalence

via llvm-bugs llvm-bugs at lists.llvm.org
Thu Nov 16 16:20:17 PST 2017


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

            Bug ID: 35337
           Summary: LLD ICF needs to consider exception tables in .xdata
                    as part of .text equivalence
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: COFF
          Assignee: unassignedbugs at nondot.org
          Reporter: rnk at google.com
                CC: llvm-bugs at lists.llvm.org

LLD mislinks this program because the .text contents of these two functions are
the same, but the .xdata exception handler table is different:

extern "C" void __ImageBase() noexcept(false);
void __declspec(dllexport) foo() {
  try {
    __ImageBase();
  } catch (int) {
  }
}
void __declspec(dllexport) baz() {
  try {
    __ImageBase();
  } catch (double) {
  }
}

Compile and link like so, and observe that the export RVAs are the same:

$ clang-cl -EHsc -O1 -MD t.cpp -c && lld-link t.obj -dll -noentry -opt:icf
-force
C:\src\llvm-project\build\bin\lld-link.exe: warning: t.obj: undefined symbol:
__CxxFrameHandler3
C:\src\llvm-project\build\bin\lld-link.exe: warning:
msvcrt.lib(delete_scalar.obj): undefined symbol: free

$ llvm-readobj -coff-exports t.dll

File: t.dll
Format: COFF-x86-64
Arch: x86_64
AddressSize: 64bit
Export {
  Ordinal: 0
  Name:
  RVA: 0x0
}
Export {
  Ordinal: 1
  Name: ?baz@@YAXXZ
  RVA: 0x6000
}
Export {
  Ordinal: 2
  Name: ?foo@@YAXXZ
  RVA: 0x6000
}

If this were a full working program, bar would not be able to catch exceptions
of type double thrown from __ImageBase and would incorrectly catch 'int'
exceptions.

-- 
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/20171117/14c7c998/attachment-0001.html>


More information about the llvm-bugs mailing list