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: unassignedb...@nondot.org
          Reporter: r...@google.com
                CC: llvm-bugs@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.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to