2020-06-14 11:00:06 +08:00
|
|
|
# REQUIRES: x86
|
|
|
|
# RUN: mkdir -p %t
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %p/Inputs/libhello.s \
|
|
|
|
# RUN: -o %t/libhello.o
|
2020-09-19 12:40:12 +08:00
|
|
|
# RUN: %lld -lSystem -dylib -install_name \
|
2020-06-14 11:00:06 +08:00
|
|
|
# RUN: @executable_path/libhello.dylib %t/libhello.o -o %t/libhello.dylib
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o
|
[lld-macho] Have tests default to targeting macos 10.15
D101114 enforced proper version checks, which exposed a variety of version
mismatch issues in our tests. We previously changed the test inputs to
target 10.0, which was the simpler thing to do, but we should really
just have our lit.local.cfg default to targeting 10.15, which is what is done
here. We're not likely to ever have proper support for the older versions
anyway, as that would require more work for unclear benefit; for instance,
llvm-mc seems to generate a different compact unwind format for older macOS
versions, which would cause our compact-unwind.s test to fail.
Targeting 10.15 by default causes the following behavioral changes:
* `__mh_execute_header` is now a section symbol instead of an absolute symbol
* LC_BUILD_VERSION gets emitted instead of LC_VERSION_MIN_MACOSX. The former is
32 bytes in size whereas the latter is 16 bytes, so a bunch of hardcoded
address offsets in our tests had to be updated.
* >= 10.6 executables are PIE by default
Note that this diff was stacked atop of a local revert of most of the test
changes in rG8c17a875150f8e736e8f9061ddf084397f45f4c5, to make review easier.
Reviewed By: #lld-macho, oontvoo
Differential Revision: https://reviews.llvm.org/D101119
2021-04-23 07:37:47 +08:00
|
|
|
|
2020-09-19 12:40:12 +08:00
|
|
|
# RUN: %lld -lSystem -o %t/test %t/test.o -L%t -lhello
|
[lld-macho] Have tests default to targeting macos 10.15
D101114 enforced proper version checks, which exposed a variety of version
mismatch issues in our tests. We previously changed the test inputs to
target 10.0, which was the simpler thing to do, but we should really
just have our lit.local.cfg default to targeting 10.15, which is what is done
here. We're not likely to ever have proper support for the older versions
anyway, as that would require more work for unclear benefit; for instance,
llvm-mc seems to generate a different compact unwind format for older macOS
versions, which would cause our compact-unwind.s test to fail.
Targeting 10.15 by default causes the following behavioral changes:
* `__mh_execute_header` is now a section symbol instead of an absolute symbol
* LC_BUILD_VERSION gets emitted instead of LC_VERSION_MIN_MACOSX. The former is
32 bytes in size whereas the latter is 16 bytes, so a bunch of hardcoded
address offsets in our tests had to be updated.
* >= 10.6 executables are PIE by default
Note that this diff was stacked atop of a local revert of most of the test
changes in rG8c17a875150f8e736e8f9061ddf084397f45f4c5, to make review easier.
Reviewed By: #lld-macho, oontvoo
Differential Revision: https://reviews.llvm.org/D101119
2021-04-23 07:37:47 +08:00
|
|
|
# RUN: llvm-objdump --macho --full-contents --rebase --bind %t/test | FileCheck %s --check-prefixes=CHECK,PIE --match-full-lines
|
2021-04-26 07:00:24 +08:00
|
|
|
# RUN: %lld -no_pie -data_const -lSystem -o %t/test %t/test.o -L%t -lhello
|
[lld-macho] Have tests default to targeting macos 10.15
D101114 enforced proper version checks, which exposed a variety of version
mismatch issues in our tests. We previously changed the test inputs to
target 10.0, which was the simpler thing to do, but we should really
just have our lit.local.cfg default to targeting 10.15, which is what is done
here. We're not likely to ever have proper support for the older versions
anyway, as that would require more work for unclear benefit; for instance,
llvm-mc seems to generate a different compact unwind format for older macOS
versions, which would cause our compact-unwind.s test to fail.
Targeting 10.15 by default causes the following behavioral changes:
* `__mh_execute_header` is now a section symbol instead of an absolute symbol
* LC_BUILD_VERSION gets emitted instead of LC_VERSION_MIN_MACOSX. The former is
32 bytes in size whereas the latter is 16 bytes, so a bunch of hardcoded
address offsets in our tests had to be updated.
* >= 10.6 executables are PIE by default
Note that this diff was stacked atop of a local revert of most of the test
changes in rG8c17a875150f8e736e8f9061ddf084397f45f4c5, to make review easier.
Reviewed By: #lld-macho, oontvoo
Differential Revision: https://reviews.llvm.org/D101119
2021-04-23 07:37:47 +08:00
|
|
|
# RUN: llvm-objdump --macho --full-contents --rebase --bind %t/test | FileCheck %s --check-prefixes=CHECK,NO-PIE --match-full-lines
|
2020-06-14 11:00:06 +08:00
|
|
|
|
|
|
|
## Check that the GOT references the cstrings. --full-contents displays the
|
|
|
|
## address offset and the contents at that address very similarly, so am using
|
|
|
|
## --match-full-lines to make sure we match on the right thing.
|
2020-09-05 01:26:09 +08:00
|
|
|
# CHECK: Contents of section __TEXT,__cstring:
|
2021-06-15 10:21:43 +08:00
|
|
|
# CHECK-NEXT: 100000444 {{.*}}
|
2020-06-14 11:00:06 +08:00
|
|
|
|
|
|
|
## 1st 8 bytes refer to the start of __cstring + 0xe, 2nd 8 bytes refer to the
|
|
|
|
## start of __cstring
|
2020-09-05 01:26:09 +08:00
|
|
|
# CHECK: Contents of section __DATA_CONST,__got:
|
2021-06-15 10:21:43 +08:00
|
|
|
# CHECK-NEXT: [[#%X,ADDR:]] 52040000 01000000 44040000 01000000 {{.*}}
|
2020-06-14 11:00:06 +08:00
|
|
|
# CHECK-NEXT: [[#ADDR + 16]] 00000000 00000000 {{.*}}
|
|
|
|
|
2020-09-06 01:55:33 +08:00
|
|
|
## Check that the rebase table is empty.
|
[lld-macho] Have tests default to targeting macos 10.15
D101114 enforced proper version checks, which exposed a variety of version
mismatch issues in our tests. We previously changed the test inputs to
target 10.0, which was the simpler thing to do, but we should really
just have our lit.local.cfg default to targeting 10.15, which is what is done
here. We're not likely to ever have proper support for the older versions
anyway, as that would require more work for unclear benefit; for instance,
llvm-mc seems to generate a different compact unwind format for older macOS
versions, which would cause our compact-unwind.s test to fail.
Targeting 10.15 by default causes the following behavioral changes:
* `__mh_execute_header` is now a section symbol instead of an absolute symbol
* LC_BUILD_VERSION gets emitted instead of LC_VERSION_MIN_MACOSX. The former is
32 bytes in size whereas the latter is 16 bytes, so a bunch of hardcoded
address offsets in our tests had to be updated.
* >= 10.6 executables are PIE by default
Note that this diff was stacked atop of a local revert of most of the test
changes in rG8c17a875150f8e736e8f9061ddf084397f45f4c5, to make review easier.
Reviewed By: #lld-macho, oontvoo
Differential Revision: https://reviews.llvm.org/D101119
2021-04-23 07:37:47 +08:00
|
|
|
# NO-PIE: Rebase table:
|
|
|
|
# NO-PIE-NEXT: segment section address type
|
2020-06-14 11:00:06 +08:00
|
|
|
|
2020-09-06 01:55:33 +08:00
|
|
|
# PIE: Rebase table:
|
|
|
|
# PIE-NEXT: segment section address type
|
|
|
|
# PIE-NEXT: __DATA_CONST __got 0x[[#%X,ADDR:]] pointer
|
|
|
|
# PIE-NEXT: __DATA_CONST __got 0x[[#ADDR + 8]] pointer
|
|
|
|
|
[lld-macho] Have tests default to targeting macos 10.15
D101114 enforced proper version checks, which exposed a variety of version
mismatch issues in our tests. We previously changed the test inputs to
target 10.0, which was the simpler thing to do, but we should really
just have our lit.local.cfg default to targeting 10.15, which is what is done
here. We're not likely to ever have proper support for the older versions
anyway, as that would require more work for unclear benefit; for instance,
llvm-mc seems to generate a different compact unwind format for older macOS
versions, which would cause our compact-unwind.s test to fail.
Targeting 10.15 by default causes the following behavioral changes:
* `__mh_execute_header` is now a section symbol instead of an absolute symbol
* LC_BUILD_VERSION gets emitted instead of LC_VERSION_MIN_MACOSX. The former is
32 bytes in size whereas the latter is 16 bytes, so a bunch of hardcoded
address offsets in our tests had to be updated.
* >= 10.6 executables are PIE by default
Note that this diff was stacked atop of a local revert of most of the test
changes in rG8c17a875150f8e736e8f9061ddf084397f45f4c5, to make review easier.
Reviewed By: #lld-macho, oontvoo
Differential Revision: https://reviews.llvm.org/D101119
2021-04-23 07:37:47 +08:00
|
|
|
## Check that a non-locally-defined symbol is still bound at the correct offset:
|
2021-05-11 00:16:18 +08:00
|
|
|
# CHECK-EMPTY:
|
[lld-macho] Have tests default to targeting macos 10.15
D101114 enforced proper version checks, which exposed a variety of version
mismatch issues in our tests. We previously changed the test inputs to
target 10.0, which was the simpler thing to do, but we should really
just have our lit.local.cfg default to targeting 10.15, which is what is done
here. We're not likely to ever have proper support for the older versions
anyway, as that would require more work for unclear benefit; for instance,
llvm-mc seems to generate a different compact unwind format for older macOS
versions, which would cause our compact-unwind.s test to fail.
Targeting 10.15 by default causes the following behavioral changes:
* `__mh_execute_header` is now a section symbol instead of an absolute symbol
* LC_BUILD_VERSION gets emitted instead of LC_VERSION_MIN_MACOSX. The former is
32 bytes in size whereas the latter is 16 bytes, so a bunch of hardcoded
address offsets in our tests had to be updated.
* >= 10.6 executables are PIE by default
Note that this diff was stacked atop of a local revert of most of the test
changes in rG8c17a875150f8e736e8f9061ddf084397f45f4c5, to make review easier.
Reviewed By: #lld-macho, oontvoo
Differential Revision: https://reviews.llvm.org/D101119
2021-04-23 07:37:47 +08:00
|
|
|
# CHECK-NEXT: Bind table:
|
|
|
|
# CHECK-NEXT: segment section address type addend dylib symbol
|
|
|
|
# CHECK-NEXT: __DATA_CONST __got 0x[[#ADDR+16]] pointer 0 libhello _hello_its_me
|
2020-09-06 01:55:33 +08:00
|
|
|
|
2020-06-14 11:00:06 +08:00
|
|
|
.globl _main
|
|
|
|
|
|
|
|
.text
|
|
|
|
_main:
|
|
|
|
movl $0x2000004, %eax # write() syscall
|
|
|
|
mov $1, %rdi # stdout
|
|
|
|
movq _hello_its_me@GOTPCREL(%rip), %rsi
|
|
|
|
mov $15, %rdx # length of str
|
|
|
|
syscall
|
|
|
|
|
|
|
|
movl $0x2000004, %eax # write() syscall
|
|
|
|
mov $1, %rdi # stdout
|
2020-08-28 06:59:45 +08:00
|
|
|
## We use pushq/popq here instead of movq in order to avoid relaxation.
|
|
|
|
pushq _hello_world@GOTPCREL(%rip)
|
|
|
|
popq %rsi
|
2020-06-14 11:00:06 +08:00
|
|
|
mov $13, %rdx # length of str
|
|
|
|
syscall
|
|
|
|
|
|
|
|
movl $0x2000004, %eax # write() syscall
|
|
|
|
mov $1, %rdi # stdout
|
2020-08-28 06:59:45 +08:00
|
|
|
pushq _goodbye_world@GOTPCREL(%rip)
|
|
|
|
popq %rsi
|
2020-06-14 11:00:06 +08:00
|
|
|
mov $15, %rdx # length of str
|
|
|
|
syscall
|
|
|
|
|
|
|
|
mov $0, %rax
|
|
|
|
ret
|
|
|
|
|
|
|
|
.section __TEXT,__cstring
|
|
|
|
_hello_world:
|
|
|
|
.asciz "Hello world!\n"
|
|
|
|
|
|
|
|
_goodbye_world:
|
|
|
|
.asciz "Goodbye world!\n"
|