<div dir="ltr">Would this be better off as a yaml2obj file as input? It would remove the assembler checks and even the dyld checks.<div><br></div><div>Thoughts?</div><div><br></div><div>-eric</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, May 11, 2020 at 12:40 PM Jez Ng via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</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"><br>
Author: Jez Ng<br>
Date: 2020-05-11T12:39:21-07:00<br>
New Revision: 723c46e645dbe23942c926d2cb800ce020df6b8b<br>
<br>
URL: <a href="https://github.com/llvm/llvm-project/commit/723c46e645dbe23942c926d2cb800ce020df6b8b" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/723c46e645dbe23942c926d2cb800ce020df6b8b</a><br>
DIFF: <a href="https://github.com/llvm/llvm-project/commit/723c46e645dbe23942c926d2cb800ce020df6b8b.diff" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project/commit/723c46e645dbe23942c926d2cb800ce020df6b8b.diff</a><br>
<br>
LOG: [lld-macho] Re-add dylink-lazy test<br>
<br>
The initial attempt didn't work on Windows; apparently Powershell has a<br>
different syntax for running commands sequentially and concatenating<br>
their outputs. So I've created two temporary files instead.<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D79697" rel="noreferrer" target="_blank">https://reviews.llvm.org/D79697</a><br>
<br>
Added: <br>
    lld/test/MachO/dylink-lazy.s<br>
<br>
Modified: <br>
<br>
<br>
Removed: <br>
<br>
<br>
<br>
################################################################################<br>
diff  --git a/lld/test/MachO/dylink-lazy.s b/lld/test/MachO/dylink-lazy.s<br>
new file mode 100644<br>
index 000000000000..c1d6275e20b4<br>
--- /dev/null<br>
+++ b/lld/test/MachO/dylink-lazy.s<br>
@@ -0,0 +1,59 @@<br>
+# REQUIRES: x86, shell<br>
+# RUN: mkdir -p %t<br>
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libhello.s \<br>
+# RUN:   -o %t/libhello.o<br>
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libgoodbye.s \<br>
+# RUN:   -o %t/libgoodbye.o<br>
+# RUN: lld -flavor darwinnew -dylib -install_name \<br>
+# RUN:   @executable_path/libhello.dylib %t/libhello.o -o %t/libhello.dylib<br>
+# RUN: lld -flavor darwinnew -dylib -install_name \<br>
+# RUN:   @executable_path/libgoodbye.dylib %t/libgoodbye.o -o %t/libgoodbye.dylib<br>
+<br>
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/dylink-lazy.o<br>
+# RUN: lld -flavor darwinnew -o %t/dylink-lazy -L%t -lhello -lgoodbye %t/dylink-lazy.o<br>
+<br>
+## When looking at the __stubs section alone, we are unable to easily tell which<br>
+## symbol each entry points to. So we call objdump twice in order to get the<br>
+## disassembly of __text and the bind tables first, which allow us to check for<br>
+## matching entries in __stubs.<br>
+# RUN: (llvm-objdump -d --no-show-raw-insn --syms --bind --lazy-bind %t/dylink-lazy; \<br>
+# RUN:  llvm-objdump -D --no-show-raw-insn %t/dylink-lazy) | FileCheck %s<br>
+<br>
+# CHECK-LABEL: SYMBOL TABLE:<br>
+# CHECK:       {{0*}}[[#%x, IMGLOADER:]] {{.*}} __DATA,__data __dyld_private<br>
+<br>
+# CHECK-LABEL: Disassembly of section __TEXT,__text:<br>
+# CHECK:         callq 0x[[#%x, HELLO_STUB:]]<br>
+# CHECK-NEXT:    callq 0x[[#%x, GOODBYE_STUB:]]<br>
+<br>
+# CHECK-LABEL: Bind table:<br>
+# CHECK:       __DATA_CONST __got 0x[[#%x, BINDER:]] pointer 0 libSystem dyld_stub_binder<br>
+<br>
+# CHECK-LABEL: Lazy bind table:<br>
+# CHECK-DAG:   __DATA __la_symbol_ptr 0x{{0*}}[[#%x, HELLO_LAZY_PTR:]] libhello _print_hello<br>
+# CHECK-DAG:   __DATA __la_symbol_ptr 0x{{0*}}[[#%x, GOODBYE_LAZY_PTR:]] libgoodbye _print_goodbye<br>
+<br>
+# CHECK-LABEL: Disassembly of section __TEXT,__stubs:<br>
+# CHECK-DAG:     [[#%x, HELLO_STUB]]:   jmpq *[[#%u, HELLO_LAZY_PTR - HELLO_STUB - 6]](%rip)<br>
+# CHECK-DAG:     [[#%x, GOODBYE_STUB]]: jmpq *[[#%u, GOODBYE_LAZY_PTR - GOODBYE_STUB - 6]](%rip)<br>
+<br>
+# CHECK-LABEL: Disassembly of section __TEXT,__stub_helper:<br>
+# CHECK:         {{0*}}[[#%x, STUB_HELPER_ENTRY:]] <__stub_helper>:<br>
+# CHECK-NEXT:    leaq [[#%u, IMGLOADER - STUB_HELPER_ENTRY - 7]](%rip), %r11<br>
+# CHECK-NEXT:    pushq %r11<br>
+# CHECK-NEXT:    jmpq *[[#%u, BINDER_OFF:]](%rip)<br>
+# CHECK-NEXT:    [[#%x, BINDER - BINDER_OFF]]: nop<br>
+# CHECK-NEXT:    pushq $0<br>
+# CHECK-NEXT:    jmp 0x[[#STUB_HELPER_ENTRY]]<br>
+# CHECK-NEXT:    pushq $21<br>
+# CHECK-NEXT:    jmp 0x[[#STUB_HELPER_ENTRY]]<br>
+<br>
+.text<br>
+.globl _main<br>
+<br>
+_main:<br>
+  sub $8, %rsp # 16-byte-align the stack; dyld checks for this<br>
+  callq _print_hello<br>
+  callq _print_goodbye<br>
+  add $8, %rsp<br>
+  ret<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>