<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 - Assert hit at lld/wasm/Symbols.cpp#L86"
   href="https://bugs.llvm.org/show_bug.cgi?id=41913">41913</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Assert hit at lld/wasm/Symbols.cpp#L86
          </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>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>wasm
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>scott.waye@hubse.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org, sbc@chromium.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I'm looking at an assert I'm hitting in ld-wasm with code as 13/05/2019
16:25:02, specifically
<a href="https://github.com/llvm/llvm-project/blob/af8cda15decac903e884015e49a043c4d58e0910/lld/wasm/Symbols.cpp#L86">https://github.com/llvm/llvm-project/blob/af8cda15decac903e884015e49a043c4d58e0910/lld/wasm/Symbols.cpp#L86</a>.
 The symbol in question has isLocal() == false (FLAGS==16).

The obvious (and probably wrong) thinking is that the problem is at
<a href="https://github.com/llvm/llvm-project/blob/af8cda15decac903e884015e49a043c4d58e0910/lld/wasm/Writer.cpp#L1094">https://github.com/llvm/llvm-project/blob/af8cda15decac903e884015e49a043c4d58e0910/lld/wasm/Writer.cpp#L1094</a>
where it only adds local symbols and hence never calls
`Sym->setOutputSymbolIndex`.  

Stack trace for assert is

        lld.exe!HandleAbort(int Sig) Line 408   C++
        [External Code] 
        lld.exe!lld::wasm::Symbol::getOutputSymbolIndex() Line 86       C++
        lld.exe!lld::wasm::ObjFile::calcNewIndex(const
llvm::wasm::WasmRelocation & Reloc) Line 79      C++
        lld.exe!lld::wasm::InputChunk::writeRelocations(llvm::raw_ostream & OS)
Line 155        C++
        lld.exe!lld::wasm::DataSection::writeRelocations(llvm::raw_ostream &
OS) Line 202       C++
        lld.exe!`anonymous namespace'::Writer::createRelocSections() Line 475  
C++
        lld.exe!`anonymous namespace'::Writer::createSections() Line 890       
C++
        lld.exe!`anonymous namespace'::Writer::run() Line 1461  C++
        lld.exe!lld::wasm::writeResult() Line 1500      C++
        lld.exe!`anonymous namespace'::LinkerDriver::link(llvm::ArrayRef<char
const *> ArgsArr) Line 628        C++
        lld.exe!lld::wasm::link(llvm::ArrayRef<char const *> Args, bool
CanExitEarly, llvm::raw_ostream & Error) Line 93        C++
        lld.exe!main(int Argc, const char * * Argv) Line 137    C++


The actual project I'm compiling is <a href="https://github.com/dotnet/corert">https://github.com/dotnet/corert</a> and the
symbol is "RhpNewFinalizable" which is declared extern in
RuntimeInstance.cpp.o:

#define DECLARE_INDIRECTION(HELPER_NAME) \
    EXTERN_C void HELPER_NAME(); \
    const PTR_VOID indirection_##HELPER_NAME = (PTR_VOID)&HELPER_NAME

DECLARE_INDIRECTION(RhpNewFinalizable);

The definition of the symbol is in portable.cpp.o which is supplied

The command line to lld is 

-flavor wasm -o libPortableRuntime.bc --allow-undefined --import-memory
--import-table --lto-O0 CMakeFiles/PortableRuntime.dir/__/allocheap.cpp.o
CMakeFiles/PortableRuntime.dir/__/rhassert.cpp.o
CMakeFiles/PortableRuntime.dir/__/CachedInterfaceDispatch.cpp.o
CMakeFiles/PortableRuntime.dir/__/Crst.cpp.o
CMakeFiles/PortableRuntime.dir/__/DebugEventSource.cpp.o
CMakeFiles/PortableRuntime.dir/__/DebugFuncEval.cpp.o
CMakeFiles/PortableRuntime.dir/__/DebuggerHook.cpp.o
CMakeFiles/PortableRuntime.dir/__/eetype.cpp.o
CMakeFiles/PortableRuntime.dir/__/EHHelpers.cpp.o
CMakeFiles/PortableRuntime.dir/__/event.cpp.o
CMakeFiles/PortableRuntime.dir/__/FinalizerHelpers.cpp.o
CMakeFiles/PortableRuntime.dir/__/GCHelpers.cpp.o
CMakeFiles/PortableRuntime.dir/__/gcheaputilities.cpp.o
CMakeFiles/PortableRuntime.dir/__/GCMemoryHelpers.cpp.o
CMakeFiles/PortableRuntime.dir/__/gcrhenv.cpp.o
CMakeFiles/PortableRuntime.dir/__/gcrhscan.cpp.o
CMakeFiles/PortableRuntime.dir/__/GcStressControl.cpp.o
CMakeFiles/PortableRuntime.dir/__/GenericUnification.cpp.o
CMakeFiles/PortableRuntime.dir/__/HandleTableHelpers.cpp.o
CMakeFiles/PortableRuntime.dir/__/MathHelpers.cpp.o
CMakeFiles/PortableRuntime.dir/__/MiscHelpers.cpp.o
CMakeFiles/PortableRuntime.dir/__/TypeManager.cpp.o
CMakeFiles/PortableRuntime.dir/__/ObjectLayout.cpp.o
CMakeFiles/PortableRuntime.dir/__/OptionalFieldsRuntime.cpp.o
CMakeFiles/PortableRuntime.dir/__/portable.cpp.o
CMakeFiles/PortableRuntime.dir/__/profheapwalkhelper.cpp.o
CMakeFiles/PortableRuntime.dir/__/RestrictedCallouts.cpp.o
CMakeFiles/PortableRuntime.dir/__/RhConfig.cpp.o
CMakeFiles/PortableRuntime.dir/__/RuntimeInstance.cpp.o
CMakeFiles/PortableRuntime.dir/__/RWLock.cpp.o
CMakeFiles/PortableRuntime.dir/__/SectionMethodList.cpp.o
CMakeFiles/PortableRuntime.dir/__/sha1.cpp.o
CMakeFiles/PortableRuntime.dir/__/StackFrameIterator.cpp.o
CMakeFiles/PortableRuntime.dir/__/startup.cpp.o
CMakeFiles/PortableRuntime.dir/__/stressLog.cpp.o
CMakeFiles/PortableRuntime.dir/__/strongname.cpp.o
CMakeFiles/PortableRuntime.dir/__/SyncClean.cpp.o
CMakeFiles/PortableRuntime.dir/__/thread.cpp.o
CMakeFiles/PortableRuntime.dir/__/threadstore.cpp.o
CMakeFiles/PortableRuntime.dir/__/UniversalTransitionHelpers.cpp.o
CMakeFiles/PortableRuntime.dir/__/__/gc/gchandletable.cpp.o
CMakeFiles/PortableRuntime.dir/__/__/gc/gccommon.cpp.o
CMakeFiles/PortableRuntime.dir/__/__/gc/gceewks.cpp.o
CMakeFiles/PortableRuntime.dir/__/__/gc/gcwks.cpp.o
CMakeFiles/PortableRuntime.dir/__/__/gc/gcscan.cpp.o
CMakeFiles/PortableRuntime.dir/__/__/gc/handletable.cpp.o
CMakeFiles/PortableRuntime.dir/__/__/gc/handletablecache.cpp.o
CMakeFiles/PortableRuntime.dir/__/__/gc/handletablecore.cpp.o
CMakeFiles/PortableRuntime.dir/__/__/gc/handletablescan.cpp.o
CMakeFiles/PortableRuntime.dir/__/__/gc/objecthandle.cpp.o
CMakeFiles/PortableRuntime.dir/__/unix/PalRedhawkUnix.cpp.o -mllvm
-combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm
-disable-lsr --export __wasm_call_ctors --export __data_end --export main
--export malloc --export free --export setThrew --export __errno_location
--export fflush -z stack-size=5242880 --initial-memory=16777216 --no-entry
--max-memory=16777216 --global-base=1024 --relocatable

If something jumps out then great, otherwise let me know and I'll try to create
a small repro.</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>