<div dir="ltr">Hi Steven,<div><br></div><div>One thing I noticed is that you are defining `memcpy`, which clang has an intrinsic with the same name. Can you try renaming it to a random name, like `foobar`, to see if the problem still exists?</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jul 16, 2019 at 10:10 AM Shi, Steven <<a href="mailto:steven.shi@intel.com">steven.shi@intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div lang="EN-US">
<div class="gmail-m_7312555612677439490WordSection1">
<p class="MsoNormal"><a name="m_7312555612677439490__MailEndCompose"><span style="color:rgb(31,73,125)">I’ve submitted a BZ for this issue as below:<u></u><u></u></span></a></p>
<p class="MsoNormal"><span style="color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p style="margin:0in 0in 0.0001pt"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:black">Bug 42626 - lld-link crash when build openssl with LTO<u></u><u></u></span></p>
<p style="margin:0in 0in 0.0001pt"><a href="https://bugs.llvm.org/show_bug.cgi?id=42626" target="_blank"><span style="font-size:11pt;font-family:Calibri,sans-serif">https://bugs.llvm.org/show_bug.cgi?id=42626</span></a><span style="font-size:11pt;font-family:Calibri,sans-serif;color:black"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:rgb(31,73,125)"><u></u> <u></u></span></p>
<div>
<p class="MsoNormal"><span style="color:rgb(31,73,125)">Thanks<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:rgb(31,73,125)">Steven<u></u><u></u></span></p>
</div>
<p class="MsoNormal"><span style="color:rgb(31,73,125)"><u></u> <u></u></span></p>
<div style="border-top:none;border-right:none;border-bottom:none;border-left:1.5pt solid blue;padding:0in 0in 0in 4pt">
<div>
<div style="border-right:none;border-bottom:none;border-left:none;border-top:1pt solid rgb(225,225,225);padding:3pt 0in 0in">
<p class="MsoNormal"><a name="m_7312555612677439490______replyseparator"></a><b>From:</b> llvm-dev [mailto:<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>]
<b>On Behalf Of </b>Shi, Steven via llvm-dev<br>
<b>Sent:</b> Monday, July 15, 2019 4:40 PM<br>
<b>To:</b> 'Rui Ueyama' <<a href="mailto:ruiu@google.com" target="_blank">ruiu@google.com</a>><br>
<b>Cc:</b> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<b>Subject:</b> [llvm-dev] lld-link crash when build openssl with LTO<u></u><u></u></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Hi Rui,<u></u><u></u></p>
<p class="MsoNormal">We met a lld-link crash problem when build 32bits openssl1.0 with LTO in uefi firmware. We narrow down and figure out a simple test case to reproduce this problem as blow. Please advise. Thank you!<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">$ cat main.c<u></u><u></u></p>
<p class="MsoNormal">void TlsDriverEntryPoint ()<u></u><u></u></p>
<p class="MsoNormal">{<u></u><u></u></p>
<p class="MsoNormal"> unsigned char *ret = 0;<u></u><u></u></p>
<p class="MsoNormal"> const unsigned char cryptopro_ext[17] = {0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01};<u></u><u></u></p>
<p class="MsoNormal"> int length =17;<u></u><u></u></p>
<p class="MsoNormal"> const char *Source;<u></u><u></u></p>
<p class="MsoNormal"> Source = (void*)cryptopro_ext;<u></u><u></u></p>
<p class="MsoNormal"> while (length--) {<u></u><u></u></p>
<p class="MsoNormal"> *(ret++) = *(Source++);<u></u><u></u></p>
<p class="MsoNormal"> }<u></u><u></u></p>
<p class="MsoNormal">}<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">$ cat memcpy.c<u></u><u></u></p>
<p class="MsoNormal">typedef unsigned int size_t;<u></u><u></u></p>
<p class="MsoNormal">void *memcpy(void *dest, const void *src, size_t n)<u></u><u></u></p>
<p class="MsoNormal">{<u></u><u></u></p>
<p class="MsoNormal"> return 0;<u></u><u></u></p>
<p class="MsoNormal">}<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">$ cat makefile<u></u><u></u></p>
<p class="MsoNormal">CC_FLAGS= -Oz -flto -target i686-unknown-windows<u></u><u></u></p>
<p class="MsoNormal">CC = /home/jshi19/llvm/llvm-project/releaseinstall/bin/clang<u></u><u></u></p>
<p class="MsoNormal">DLINK_FLAGS = /MACHINE:X86 /DLL /ENTRY:TlsDriverEntryPoint<u></u><u></u></p>
<p class="MsoNormal">DLINK = /home/jshi19/llvm/llvm-project/releaseinstall/bin/lld-link<u></u><u></u></p>
<p class="MsoNormal">SLINK_FLAGS =<u></u><u></u></p>
<p class="MsoNormal">SLINK = /home/jshi19/llvm/llvm-project/releaseinstall/bin/llvm-lib<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">build:<u></u><u></u></p>
<p class="MsoNormal"> "$(CC)" $(CC_FLAGS) -c -o main.obj main.c<u></u><u></u></p>
<p class="MsoNormal"> "$(CC)" $(CC_FLAGS) -c -o memcpy.obj memcpy.c<u></u><u></u></p>
<p class="MsoNormal"> "$(SLINK)" $(SLINK_FLAGS) /OUT:main.lib main.obj<u></u><u></u></p>
<p class="MsoNormal"> "$(SLINK)" $(SLINK_FLAGS) /OUT:memcpy.lib memcpy.obj<u></u><u></u></p>
<p class="MsoNormal"> "$(DLINK)" /OUT:f.dll $(DLINK_FLAGS) main.lib memcpy.lib<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">$ make<u></u><u></u></p>
<p class="MsoNormal">"/home/jshi19/llvm/llvm-project/releaseinstall/bin/clang" -Oz -flto -target i686-unknown-windows -c -o main.obj main.c<u></u><u></u></p>
<p class="MsoNormal">"/home/jshi19/llvm/llvm-project/releaseinstall/bin/clang" -Oz -flto -target i686-unknown-windows -c -o memcpy.obj memcpy.c<u></u><u></u></p>
<p class="MsoNormal">"/home/jshi19/llvm/llvm-project/releaseinstall/bin/llvm-lib" /OUT:main.lib main.obj<u></u><u></u></p>
<p class="MsoNormal">"/home/jshi19/llvm/llvm-project/releaseinstall/bin/llvm-lib" /OUT:memcpy.lib memcpy.obj<u></u><u></u></p>
<p class="MsoNormal">"/home/jshi19/llvm/llvm-project/releaseinstall/bin/lld-link" /OUT:f.dll /MACHINE:X86 /DLL /ENTRY:TlsDriverEntryPoint main.lib memcpy.lib<u></u><u></u></p>
<p class="MsoNormal">Stack dump:<u></u><u></u></p>
<p class="MsoNormal">0. Program arguments: /home/jshi19/llvm/llvm-project/releaseinstall/bin/lld-link /OUT:f.dll /MACHINE:X86 /DLL /ENTRY:TlsDriverEntryPoint main.lib memcpy.lib<u></u><u></u></p>
<p class="MsoNormal">#0 0x000055f11ed8585a llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/jshi19/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:498:0<u></u><u></u></p>
<p class="MsoNormal">#1 0x000055f11ed83684 llvm::sys::RunSignalHandlers() /home/jshi19/llvm/llvm-project/llvm/lib/Support/Signals.cpp:68:0<u></u><u></u></p>
<p class="MsoNormal">#2 0x000055f11ed837c2 SignalHandler(int) /home/jshi19/llvm/llvm-project/llvm/lib/Support/Unix/Signals.inc:357:0<u></u><u></u></p>
<p class="MsoNormal">#3 0x00007f172a5f2890 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x12890)<u></u><u></u></p>
<p class="MsoNormal">#4 0x000055f11edd8025 lld::coff::DefinedRegular::getChunk() const /home/jshi19/llvm/llvm-project/lld/COFF/Symbols.h:176:0<u></u><u></u></p>
<p class="MsoNormal">#5 0x000055f11edd8025 operator() /home/jshi19/llvm/llvm-project/lld/COFF/MarkLive.cpp:46:0<u></u><u></u></p>
<p class="MsoNormal">#6 0x000055f11edd8025 lld::coff::markLive(llvm::ArrayRef<lld::coff::Chunk*>) /home/jshi19/llvm/llvm-project/lld/COFF/MarkLive.cpp:55:0<u></u><u></u></p>
<p class="MsoNormal">#7 0x000055f11edb763e std::vector<lld::coff::Chunk*, std::allocator<lld::coff::Chunk*> >::~vector() /usr/include/c++/7/bits/stl_vector.h:434:0<u></u><u></u></p>
<p class="MsoNormal">#8 0x000055f11edb763e lld::coff::LinkerDriver::link(llvm::ArrayRef<char const*>) /home/jshi19/llvm/llvm-project/lld/COFF/Driver.cpp:1840:0<u></u><u></u></p>
<p class="MsoNormal">#9 0x000055f11edb7d08 lld::coff::link(llvm::ArrayRef<char const*>, bool, llvm::raw_ostream&) /home/jshi19/llvm/llvm-project/lld/COFF/Driver.cpp:78:0<u></u><u></u></p>
<p class="MsoNormal">#10 0x000055f11ecfa044 main /home/jshi19/llvm/llvm-project/lld/tools/lld/lld.cpp:155:0<u></u><u></u></p>
<p class="MsoNormal">#11 0x00007f17290c9b97 __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:344:0<u></u><u></u></p>
<p class="MsoNormal">#12 0x000055f11ed555ba _start (/home/jshi19/llvm/llvm-project/releaseinstall/bin/lld-link+0x25a5ba)<u></u><u></u></p>
<p class="MsoNormal">Segmentation fault (core dumped)<u></u><u></u></p>
<p class="MsoNormal">makefile:12: recipe for target 'build' failed<u></u><u></u></p>
<p class="MsoNormal">make: *** [build] Error 139<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Steven<u></u><u></u></p>
<p class="MsoNormal">Thanks<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
</div>
</div>
</blockquote></div>