2021-03-18 22:38:30 +08:00
|
|
|
# REQUIRES: x86
|
|
|
|
# RUN: rm -rf %t; split-file %s %t
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
|
2022-02-12 08:33:23 +08:00
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/c-string-literal.s -o %t/c-string-literal.o
|
2021-03-18 22:38:30 +08:00
|
|
|
|
2022-01-12 09:45:07 +08:00
|
|
|
# RUN: %lld -map %t/map %t/test.o %t/foo.o --time-trace -o %t/test-map
|
2021-03-18 22:38:30 +08:00
|
|
|
# RUN: llvm-objdump --syms --section-headers %t/test-map > %t/objdump
|
|
|
|
# RUN: cat %t/objdump %t/map > %t/out
|
|
|
|
# RUN: FileCheck %s < %t/out
|
2022-01-12 09:45:07 +08:00
|
|
|
# RUN: FileCheck %s --check-prefix=MAPFILE < %t/test-map.time-trace
|
2021-03-18 22:38:30 +08:00
|
|
|
|
|
|
|
# CHECK: Sections:
|
|
|
|
# CHECK-NEXT: Idx Name Size VMA Type
|
|
|
|
# CHECK-NEXT: 0 __text {{[0-9a-f]+}} [[#%x,TEXT:]] TEXT
|
|
|
|
# CHECK-NEXT: 1 obj {{[0-9a-f]+}} [[#%x,DATA:]] DATA
|
|
|
|
# CHECK-NEXT: 2 __common {{[0-9a-f]+}} [[#%x,BSS:]] BSS
|
|
|
|
|
|
|
|
# CHECK: SYMBOL TABLE:
|
|
|
|
# CHECK-NEXT: [[#%x,MAIN:]] g F __TEXT,__text _main
|
|
|
|
# CHECK-NEXT: [[#%x,NUMBER:]] g O __DATA,__common _number
|
|
|
|
# CHECK-NEXT: [[#%x,FOO:]] g O __TEXT,obj _foo
|
[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: [[#%x,HEADER:]] g F __TEXT,__text __mh_execute_header
|
2021-03-18 22:38:30 +08:00
|
|
|
|
|
|
|
# CHECK-NEXT: # Path: {{.*}}{{/|\\}}map-file.s.tmp/test-map
|
|
|
|
# CHECK-NEXT: # Arch: x86_64
|
|
|
|
# CHECK-NEXT: # Object files:
|
|
|
|
# CHECK-NEXT: [ 0] linker synthesized
|
|
|
|
# CHECK-NEXT: [ 1] {{.*}}{{/|\\}}map-file.s.tmp/test.o
|
|
|
|
# CHECK-NEXT: [ 2] {{.*}}{{/|\\}}map-file.s.tmp/foo.o
|
|
|
|
|
|
|
|
# CHECK-NEXT: # Sections:
|
|
|
|
# CHECK-NEXT: # Address Size Segment Section
|
|
|
|
# CHECK-NEXT: 0x[[#TEXT]] 0x{{[0-9a-f]+}} __TEXT __text
|
|
|
|
# CHECK-NEXT: 0x[[#DATA]] 0x{{[0-9a-f]+}} __TEXT obj
|
|
|
|
# CHECK-NEXT: 0x[[#BSS]] 0x{{[0-9a-f]+}} __DATA __common
|
|
|
|
|
|
|
|
# CHECK-NEXT: # Symbols:
|
|
|
|
# CHECK-NEXT: # Address File Name
|
|
|
|
# CHECK-NEXT: 0x[[#MAIN]] [ 1] _main
|
|
|
|
# CHECK-NEXT: 0x[[#FOO]] [ 2] _foo
|
2022-01-21 04:13:04 +08:00
|
|
|
# CHECK-NEXT: 0x[[#NUMBER]] [ 1] _number
|
2022-01-12 09:45:07 +08:00
|
|
|
|
2022-02-12 08:33:23 +08:00
|
|
|
# RUN: %lld -map %t/c-string-literal-map %t/c-string-literal.o -o %t/c-string-literal-out
|
|
|
|
# RUN: FileCheck --check-prefix=CSTRING %s < %t/c-string-literal-map
|
|
|
|
|
|
|
|
## C-string literals should be printed as "literal string: <C string literal>"
|
|
|
|
# CSTRING-LABEL: Symbols:
|
|
|
|
# CSTRING-DAG: _main
|
|
|
|
# CSTRING-DAG: literal string: Hello world!\n
|
|
|
|
# CSTRING-DAG: literal string: Hello, it's me
|
|
|
|
|
|
|
|
# RUN: %lld -dead_strip -map %t/dead-c-string-literal-map %t/c-string-literal.o -o %t/dead-c-string-literal-out
|
|
|
|
# RUN: FileCheck --check-prefix=DEADCSTRING %s < %t/dead-c-string-literal-map
|
|
|
|
|
|
|
|
## C-string literals should be printed as "literal string: <C string literal>"
|
|
|
|
# DEADCSTRING-LABEL: Symbols:
|
|
|
|
# DEADCSTRING-DAG: _main
|
|
|
|
# DEADCSTRING-DAG: literal string: Hello world!\n
|
|
|
|
# DEADCSTRING-LABEL: Dead Stripped Symbols:
|
|
|
|
# DEADCSTRING-DAG: literal string: Hello, it's me
|
|
|
|
|
2022-01-12 15:00:56 +08:00
|
|
|
# MAPFILE: "name":"Total Write map file"
|
2022-02-12 08:40:53 +08:00
|
|
|
|
|
|
|
#--- foo.s
|
|
|
|
.section __TEXT,obj
|
|
|
|
.globl _foo
|
|
|
|
_foo:
|
|
|
|
|
|
|
|
#--- test.s
|
|
|
|
.comm _number, 1
|
|
|
|
.globl _main
|
|
|
|
_main:
|
|
|
|
ret
|
|
|
|
|
|
|
|
#--- c-string-literal.s
|
|
|
|
.section __TEXT,__cstring
|
|
|
|
.globl _hello_world, _hello_its_me, _main
|
|
|
|
|
|
|
|
_hello_world:
|
|
|
|
.asciz "Hello world!\n"
|
|
|
|
|
|
|
|
_hello_its_me:
|
|
|
|
.asciz "Hello, it's me"
|
|
|
|
|
|
|
|
.text
|
|
|
|
_main:
|
|
|
|
movl $0x2000004, %eax # write() syscall
|
|
|
|
mov $1, %rdi # stdout
|
|
|
|
leaq _hello_world(%rip), %rsi
|
|
|
|
mov $13, %rdx # length of str
|
|
|
|
syscall
|
|
|
|
ret
|