<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - lld-link reporting undefined symbol with lto"
href="https://bugs.llvm.org/show_bug.cgi?id=42536">42536</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>lld-link reporting undefined symbol with lto
</td>
</tr>
<tr>
<th>Product</th>
<td>lld
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Windows NT
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>enhancement
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>COFF
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>russell_gallop@sn.scee.net
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=22205" name="attach_22205" title="Reproducible">attachment 22205</a> <a href="attachment.cgi?id=22205&action=edit" title="Reproducible">[details]</a></span>
Reproducible
lld-link 8.0.0 crashes when reporting an undefined symbol (still present at
r364942).
(note that the test case below wouldn't link successfully with the bug fixed
due to the undefined symbols).
--- library.cpp
struct S {
virtual void foo() {}
};
void a() { S b; }
--- main.cpp
struct __declspec(dllimport) S {
virtual void foo();
};
struct a {
a();
};
struct {
a b;
S c;
} d;
<span class="quote">> clang-cl /c /nologo /O2 /MT /TP -m64 -flto library.cpp
> llvm-lib /OUT:library.lib /NOLOGO library.obj
> clang-cl /c /nologo /O2 /MT /TP -m64 -flto main.cpp
>lld-link /OUT:test.exe "library.lib" "main.obj" /MACHINE:X64 /INCREMENTAL:NO /SUBSYSTEM:CONSOLE /ERRORREPORT:PROMPT /NOLOGO /NODEFAULTLIB</span >
lld-link: error: <root>: undefined symbol: mainCRTStartup
Stack dump:
0. Program arguments: lld-link /OUT:test.exe library.lib main.obj
/MACHINE:X64 /INCREMENTAL:NO /SUBSYSTEM:CONSOLE /ERRORREPORT:PROMPT /NOLOGO
/NODEFAULTLIB
#0 0x00007ff6b77886d3 lld::coff::getSymbol
F:\git\llvm-project\lld\COFF\SymbolTable.cpp:72:0
#1 0x00007ff6b7787c0c lld::coff::getSymbolLocations(class lld::coff::ObjFile
*,unsigned int) F:\git\llvm-project\lld\COFF\SymbolTable.cpp:102:0
#2 0x00007ff6b778bcaf lld::coff::reportUndefinedSymbol
F:\git\llvm-project\lld\COFF\SymbolTable.cpp:147:0
#3 0x00007ff6b778b498 lld::coff::SymbolTable::reportRemainingUndefines(void)
F:\git\llvm-project\lld\COFF\SymbolTable.cpp:331:0
#4 0x00007ff6b76f0437 lld::coff::LinkerDriver::link(class llvm::ArrayRef<char
const *>) F:\git\llvm-project\lld\COFF\Driver.cpp:1761:0
#5 0x00007ff6b76e89e1 lld::coff::link(class llvm::ArrayRef<char const
*>,bool,class llvm::raw_ostream &) F:\git\llvm-project\lld\COFF\Driver.cpp:78:0
#6 0x00007ff6b76b1227 main F:\git\llvm-project\lld\tools\lld\lld.cpp:155:0
#7 0x00007ff6b95fbc94 __scrt_common_main_seh
d:\agent\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288:0
#8 0x00007ffe2d414034 (C:\WINDOWS\System32\KERNEL32.DLL+0x14034)
#9 0x00007ffe2e553691 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x73691)
Without -flto this reports:
lld-link: error: <root>: undefined symbol: mainCRTStartup
lld-link: error: undefined symbol: public: __cdecl a::a(void)
<span class="quote">>>> referenced by main.obj:(_GLOBAL__sub_I_main.cpp)</span >
lld-link: error: undefined symbol: const type_info::`vftable'
<span class="quote">>>> referenced by main.obj:(struct S `RTTI Type Descriptor')
>>> referenced by library.lib(library.obj)</span ></pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>