[lld] 723c46e - [lld-macho] Re-add dylink-lazy test

Eric Christopher via llvm-commits llvm-commits at lists.llvm.org
Mon May 11 19:48:19 PDT 2020


Hi Jez,

I've reverted this temporarily. I'm not certain this is working yet as I
hope the following shell transcript shows:

echristo at athyra ~/tmp> ~/builds/build-llvm/bin/llvm-mc -filetype=obj
-triple=x86_64-apple-darwin libhello.s -o libhello.o
echristo at athyra ~/tmp> ~/builds/build-llvm/bin/llvm-mc -filetype=obj
-triple=x86_64-apple-darwin libgoodbye.s -o libgoodbye.o
echristo at athyra ~/tmp> ~/builds/build-llvm/bin/llvm-mc -filetype=obj
-triple=x86_64-apple-darwin dylink-lazy.s  -o dylink-lazy.o
echristo at athyra ~/tmp> ~/builds/build-llvm/bin/lld -flavor darwinnew -dylib
-install_name @executable_path/libhello.dylib libhello.o -o libhello.dylib
echristo at athyra ~/tmp> ~/builds/build-llvm/bin/lld -flavor darwinnew -dylib
-install_name @executable_path/libgoodbye.dylib libgoodbye.o -o
libgoodbye.dylib
echristo at athyra ~/tmp> ~/builds/build-llvm/bin/lld -flavor darwinnew -o
dylink-lazy -L. -lhello -lgoodbye dylink-lazy.o
lld: error: symbol dyld_stub_binder not found (normally in
libSystem.dylib). Needed to perform lazy binding.

I think something going on in the test harness versus locally is an issue.
Happy to help you debug it if there's anything I can do. I could easily be
holding it wrong - please let me know if so :)

Reverted thusly:

echristo at athyra ~/r/llvm-project> git push origin
eb81de2de4003e3045fdf743e093f77e37aee9bf:master
To github.com:llvm/llvm-project.git
   e8c13c182a5..eb81de2de40  eb81de2de4003e3045fdf743e093f77e37aee9bf ->
master

Thanks!

-eric

On Mon, May 11, 2020 at 4:36 PM Eric Christopher <echristo at gmail.com> wrote:

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


More information about the llvm-commits mailing list