<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>I found something, a real difference between the log in 32 arch
      and the log in 64 arch by running</p>
    <ol>
      <li>lli.exe -debug hw-m32.ll > lli-hw-m32.log 2>&1</li>
      <li>lli.exe -debug hw-m64.ll > lli-hw-m64.log 2>&1</li>
    </ol>
    <p>In the 32 case, there is a undefined symbol: ErrorStr    "Symbol
      not found: ___acrt_iob_func"    std::string, and in fact, the
      symbol '___acrt_iob_func' (with 3 '_' before) does not exist in
      the C:\WINDOWS\SYSTEM32\ucrtbased.dll, but there is a
      '__acrt_iob_func' (2 '_' before) symbol exported.</p>
    <p>The other strange thing is that in the lli-hw-m64.log, there is
      never a '___acrt_iob_func' but only '__acrt_iob_func' references
      and the lli 64 execution is working fine. And the assert below</p>
    <p> uint8_t *getAddressWithOffset(unsigned OffsetBytes) const {<br>
          assert(OffsetBytes <= AllocationSize && "Offset out
      of bounds!");<br>
          return Address + OffsetBytes;<br>
        }</p>
    <p>is failing around solving a relocation of   '___acrt_iob_func' 
      in the section 4. Thus, I am suggesting that solving the undefined
      issue on '___acrt_iob_func' should solve the issue<br>
    </p>
    <p>The llvm::RuntimeDynldCOOF is too much complex for me to jump
      into. To whom, I could submit those informations for a fix?<br>
    </p>
    <div class="moz-cite-prefix">Le 09/03/2021 à 21:22, Chris Tetreault
      via llvm-dev a écrit :<br>
    </div>
    <blockquote type="cite"
cite="mid:BYAPR02MB45515A46DACAD03981FDF8E7DA929@BYAPR02MB4551.namprd02.prod.outlook.com">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style>@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}span.EmailStyle19
        {mso-style-type:personal-compose;}.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}div.WordSection1
        {page:WordSection1;}</style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
      <div class="WordSection1">
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">You should be able to directly debug in
          visual studio. Build and run lli with your hw-m32.ll added to
          the debug args. Make sure you do a debug build. The assert
          should cause the visual studio debugger to break and you can
          examine the call stack and figure out relevant breakpoints to
          set.<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <div>
          <div style="border:none;border-top:solid #E1E1E1
            1.0pt;padding:3.0pt 0in 0in 0in">
            <p class="MsoNormal"><b>From:</b> llvm-dev <<a
                href="mailto:llvm-dev-bounces@lists.llvm.org"
                moz-do-not-send="true">llvm-dev-bounces@lists.llvm.org</a>>
              <b>On Behalf Of </b>Francis ANDRE via llvm-dev<br>
              <b>Sent:</b> Tuesday, March 9, 2021 10:34 AM<br>
              <b>To:</b> LLVM Developers' List <<a
                href="mailto:llvm-dev@lists.llvm.org"
                moz-do-not-send="true">llvm-dev@lists.llvm.org</a>><br>
              <b>Subject:</b> [EXT] [llvm-dev] Help: Windows: lli
              crashes on 32 arch but not on 64 arch<o:p></o:p></p>
          </div>
        </div>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">Hello LLVM list<o:p></o:p></p>
        <p>I am running with lli,  a simple HelloWorld program twice,
          once targeted to 32 bits arch, the other targeted to 64 bit
          arch. While it is working fine with the 64 arch, it craches
          with the 32 arch. Below are the steps<o:p></o:p></p>
        <p><o:p> </o:p></p>
        <p>clang.cmd -v -g -m64 -emit-llvm -S hw.c -o hw-m64.ll<o:p></o:p></p>
        <p><o:p> </o:p></p>
        <p class="MsoNormal">clang.cmd -v -g -m32 -emit-llvm -S hw.c -o
          hw-m32.ll<o:p></o:p></p>
        <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
          <p class="MsoNormal">C:\Program Files
            (x86)\LLVM\11.0\bin"\clang -v -g -m32 -emit-llvm -S e.c -o
            e-m32.ll<br>
            clang version 11.0.0<br>
            Target: i686-pc-windows-msvc<br>
            Thread model: posix<br>
            InstalledDir: C:\Program Files (x86)\LLVM\11.0\bin<br>
             (in-process)<br>
             "C:\\Program Files (x86)<a
              href="file://LLVM/11.0/bin/clang.exe"
              moz-do-not-send="true">\\LLVM\\11.0\\bin\\clang.exe</a>"
            -cc1 -triple i686-pc-windows-msvc19.28.29335 -emit-llvm
            -disable-free -disable-llvm-verifier -discard-value-names
            -main-file-name e.c -mrelocation-model static
            -mframe-pointer=all -fmath-errno -fno-rounding-math
            -mconstructor-aliases -target-cpu pentium4 -gno-column-info
            -gcodeview -debug-info-kind=limited -v -resource-dir
            "C:\\Program Files (x86)<a
              href="file://LLVM/11.0/lib/clang/11.0.0"
              moz-do-not-send="true">\\LLVM\\11.0\\lib\\clang\\11.0.0</a>"
            -internal-isystem "C:\\Program Files (x86)<a
              href="file://LLVM/11.0/lib/clang/11.0.0/include"
              moz-do-not-send="true">\\LLVM\\11.0\\lib\\clang\\11.0.0\\include</a>"
            -internal-isystem "C:\\Program Files (x86)<a
              href="file://Microsoft" moz-do-not-send="true">\\Microsoft</a>
            Visual
            Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.28.29333\\include"
            -internal-isystem "C:\\Program Files (x86)<a
              href="file://Microsoft" moz-do-not-send="true">\\Microsoft</a>
            Visual
            Studio\\2019\\Community\\VC\\Tools\\MSVC\\14.28.29333\\atlmfc\\include"
            -internal-isystem "C:\\Program Files (x86)<a
              href="file://Windows" moz-do-not-send="true">\\Windows</a>
            Kits\\10\\Include\\10.0.18362.0\\ucrt" -internal-isystem
            "C:\\Program Files (x86)<a href="file://Windows"
              moz-do-not-send="true">\\Windows</a>
            Kits\\10\\include\\10.0.18362.0\\shared" -internal-isystem
            "C:\\Program Files (x86)<a href="file://Windows"
              moz-do-not-send="true">\\Windows</a>
            Kits\\10\\include\\10.0.18362.0\\um" -internal-isystem
            "C:\\Program Files (x86)<a href="file://Windows"
              moz-do-not-send="true">\\Windows</a>
            Kits\\10\\include\\10.0.18362.0\\winrt"
            -fdebug-compilation-dir "D:\\projects\\as400\\rpg\\clang"
            -ferror-limit 19 -fmessage-length=194 -fno-use-cxa-atexit
            -fms-extensions -fms-compatibility
            -fms-compatibility-version=19.28.29335
            -fdelayed-template-parsing -fcolor-diagnostics -faddrsig -o
            e-m32.ll -x c e.c<br>
            clang -cc1 version 11.0.0 based upon LLVM 11.0.0 default
            target i686-pc-windows-msvc<br>
            #include "..." search starts here:<br>
            #include <...> search starts here:<br>
             C:\Program Files (x86)\LLVM\11.0\lib\clang\11.0.0\include<br>
             C:\Program Files (x86)\Microsoft Visual
            Studio\2019\Community\VC\Tools\MSVC\14.28.29333\include<br>
             C:\Program Files (x86)\Microsoft Visual
            Studio\2019\Community\VC\Tools\MSVC\14.28.29333\atlmfc\include<br>
             C:\Program Files (x86)\Windows
            Kits\10\Include\10.0.18362.0\ucrt<br>
             C:\Program Files (x86)\Windows
            Kits\10\include\10.0.18362.0\shared<br>
             C:\Program Files (x86)\Windows
            Kits\10\include\10.0.18362.0\um<br>
             C:\Program Files (x86)\Windows
            Kits\10\include\10.0.18362.0\winrt<br>
            End of search list.<o:p></o:p></p>
        </blockquote>
        <p class="MsoNormal">lli hw-m64.ll<o:p></o:p></p>
        <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
          <p class="MsoNormal">Hello World!<o:p></o:p></p>
        </blockquote>
        <p class="MsoNormal">lli hw-m32.ll<o:p></o:p></p>
        <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
          <p class="MsoNormal">PLEASE submit a bug report to <a
              href="https://bugs.llvm.org/" moz-do-not-send="true">
              https://bugs.llvm.org/</a> and include the crash
            backtrace.<br>
            Stack dump:<br>
            0.      Program arguments:
            D:\\llvm-project\\build32\\Debug\\bin\\lli hw-m32.ll<br>
             #0 0x04b8eacc<br>
             #1 0x03ff017b<br>
             #2 0x03ff032b<br>
             #3 0x0153ca18 llvm::MCJIT::runFunction(class llvm::Function
            *, class llvm::ArrayRef<struct llvm::GenericValue>)
            D:\llvm-project\llvm\lib\ExecutionEngine\MCJIT\MCJIT.cpp:587:0<br>
             #4 0x01459673
            llvm::ExecutionEngine::runFunctionAsMain(class
            llvm::Function *, class std::vector<class
            std::basic_string<char, struct
            std::char_traits<char>, class
            std::allocator<char>>, class
            std::allocator<class std::basic_string<char, struct
            std::char_traits<char>, class
            std::allocator<char>>>> const &, char
            const *const *)
            D:\llvm-project\llvm\lib\ExecutionEngine\ExecutionEngine.cpp:467:0<br>
             #5 0x007e08c5 main
            D:\llvm-project\llvm\tools\lli\lli.cpp:643:0<br>
             #6 0x02e12013 invoke_main
d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:78:0<br>
             #7 0x02e11e97 _scrt_common_main_seh
d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288:0<br>
             #8 0x02e11d2d _scrt_common_main
d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:331:0<br>
             #9 0x02e12098 mainCRTStartup
d:\agent\_work\57\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp:17:0<br>
            #10 0x75336359 (C:\WINDOWS\System32\KERNEL32.DLL+0x16359)<br>
            #11 0x774c8944 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x68944)<br>
            #12 0x774c8914 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x68914)<o:p></o:p></p>
        </blockquote>
        <p>What is the best way to debug the 32 bit arch lli.exe under
          VS2019?<o:p></o:p></p>
        <p><o:p> </o:p></p>
        <p class="MsoNormal" style="margin-bottom:12.0pt">D:\projects\clang>type
          hw.c<br>
          #include <stdio.h><br>
          int main() {<br>
                  printf("Hello World!\n");<br>
                  return 0;<br>
          }<o:p></o:p></p>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
    </blockquote>
  </body>
</html>