<div dir="auto"><div><br><div class="gmail_extra"><br><div class="gmail_quote">On Jul 14, 2017 10:58, "Jean-Daniel via llvm-dev" <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">LLD Mach-O support was experimental and AFAIK it is unmaintained. It lacks a lots of features to be usable. The only supported linker on macOS is ld64.</div></blockquote></div></div></div><div dir="auto"><br></div><div dir="auto">Surely this is not the end-game?</div><div dir="auto"><br></div><div dir="auto">Patricio has submitted a patch to fix this particular issue. Please let us move LLD forward enough in the meantime until llvm devs consider mach-o a first class target of LLD.</div><div dir="auto"><br></div><div dir="auto"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div><br><div><blockquote type="cite"><div class="elided-text"><div>Le 10 juil. 2017 à 17:36, Patricio Villalobos via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> a écrit :</div><br class="m_-5068944435762990718Apple-interchange-newline"></div><div><div class="elided-text"><div dir="ltr">I discovered that lld for darwin is generating the wrong code for lazy bindings in the __stub_helper section (at least for osx 10.12). This is the way i can reproduce this problem, using this program:<div><br></div><div>program:</div><div><br></div><div><div><font face="monospace, monospace">#include <stdio.h></font></div><div><font face="monospace, monospace"><br></font></div><div><font face="monospace, monospace">int main(int argc, char **argv) {</font></div><div><font face="monospace, monospace">    printf("C: printf!\n");</font></div><div><font face="monospace, monospace">    puts("C: puts!\n");</font></div><div><font face="monospace, monospace">    return 0;</font></div><div><font face="monospace, monospace">}</font></div><div><br></div><div>Then I link it using i have tested it in 3.9, 4.0 and 4.1 versions:</div><div><br></div><div><font face="monospace, monospace">clang -c hello.c</font></div><div><font face="monospace, monospace">lld -flavor darwin hello.o -o h1  -lc<br></font></div><div><br></div><div>When i execute the binary h1 the system gives me the following error:</div><div><br></div><div><div><font face="monospace, monospace">C: printf!</font></div><div><font face="monospace, monospace">dyld: lazy symbol binding failed: BIND_OPCODE_SET_SEGMENT_AND_<wbr>OFFSET_ULEB has segment 4 which is too large (0..3)</font></div><div><font face="monospace, monospace">dyld: BIND_OPCODE_SET_SEGMENT_AND_<wbr>OFFSET_ULEB has segment 4 which is too large (0..3)</font></div><div><font face="monospace, monospace">Trace/BPT trap: 5</font></div></div><div><br></div><div>Investigating the code, it seems that the problem is that the asm code generated in the file StubPass.cpp, specifically in the line <a href="https://github.com/llvm-mirror/lld/blob/master/lib/ReaderWriter/MachO/StubsPass.cpp#L323" target="_blank">323</a> ,when it adds, what it seems an arbitrary number (12) to the offset into the lazy bind opcodes section, but it should be calculated depending on the <font face="monospace, monospace">MachONormalizedFileBinaryW<wbr>rite::lazyBindingInfo</font> result.</div><div><br></div><div>I confirmed this bug by patching the code manually in the binary and writing the right offset in the asm code (__stub_helper). I'm yet not familiarized with the code , so i can't fix it right now , Im unable to find the information of the symbols that <font face="monospace, monospace">MachONormalizedFileBinaryWrite<wbr>::buildLazyBindInfo</font> has ,since is generated after the pass.</div><div><br></div><div>I'll be glad to receive guidance so i can fix it myself and familiarize myself with the code.<br></div><div><br></div><div><br></div>-- <br><div class="m_-5068944435762990718gmail_signature"><div dir="ltr">Patricio<div><br></div></div></div>
</div></div></div>
______________________________<wbr>_________________<br>LLVM Developers mailing list<br><a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br></div></blockquote></div><br></div></div><br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div></div></div>