1 # REQUIRES: x86, aarch64
2 # RUN: rm -rf %t; mkdir -p %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/x86_64.o
4 # RUN: llvm-mc -filetype=obj -triple=arm64_32-apple-watchos %s -o %t/arm64-32.o
5 # RUN: %lld -o %t/x86_64 %t/x86_64.o
6 # RUN: %lld-watchos -o %t/arm64_32 %t/arm64-32.o
8 # RUN: llvm-readobj --macho-segment %t/x86_64 > %t/x86_64.out
9 # RUN: echo "Total file size" >> %t/x86_64.out
10 # RUN: wc -c %t/x86_64 >> %t/x86_64.out
11 # RUN: FileCheck %s -DSUFFIX=_64 -DPAGEZERO_SIZE=0x100000000 -DTEXT_ADDR=0x100000000 < %t/x86_64.out
13 # RUN: llvm-readobj --macho-segment %t/arm64_32 > %t/arm64-32.out
14 # RUN: echo "Total file size" >> %t/arm64-32.out
15 # RUN: wc -c %t/arm64_32 >> %t/arm64-32.out
16 # RUN: FileCheck %s -DSUFFIX= -DPAGEZERO_SIZE=0x4000 -DTEXT_ADDR=0x4000 < %t/arm64-32.out
18 ## These two segments must always be present at the start of an executable.
19 # CHECK-NOT: Segment {
21 # CHECK-NEXT: Cmd: LC_SEGMENT[[SUFFIX]]{{$}}
22 # CHECK-NEXT: Name: __PAGEZERO
24 # CHECK-NEXT: vmaddr: 0x0
25 # CHECK-NEXT: vmsize: [[PAGEZERO_SIZE]]
26 # CHECK-NEXT: fileoff: 0
27 # CHECK-NEXT: filesize: 0
28 ## The kernel won't execute a binary with the wrong protections for __PAGEZERO.
29 # CHECK-NEXT: maxprot: ---
30 # CHECK-NEXT: initprot: ---
31 # CHECK-NEXT: nsects: 0
32 # CHECK-NEXT: flags: 0x0
34 # CHECK-NEXT: Segment {
35 # CHECK-NEXT: Cmd: LC_SEGMENT[[SUFFIX]]{{$}}
36 # CHECK-NEXT: Name: __TEXT
38 # CHECK-NEXT: vmaddr: [[TEXT_ADDR]]
40 ## dyld3 assumes that the __TEXT segment starts from the file header
41 # CHECK-NEXT: fileoff: 0
42 # CHECK-NEXT: filesize:
43 # CHECK-NEXT: maxprot: r-x
44 # CHECK-NEXT: initprot: r-x
45 # CHECK-NEXT: nsects: 1
46 # CHECK-NEXT: flags: 0x0
49 ## Check that we handle max-length names correctly.
50 # CHECK: Cmd: LC_SEGMENT[[SUFFIX]]{{$}}
51 # CHECK-NEXT: Name: maxlen_16ch_name
53 ## This segment must always be present at the end of an executable, and cover
55 # CHECK: Name: __LINKEDIT
59 # CHECK-NEXT: fileoff: [[#%u, LINKEDIT_OFF:]]
60 # CHECK-NEXT: filesize: [[#%u, LINKEDIT_SIZE:]]
61 # CHECK-NEXT: maxprot: r--
62 # CHECK-NEXT: initprot: r--
63 # CHECK-NOT: Cmd: LC_SEGMENT[[SUFFIX]]{{$}}
65 # CHECK-LABEL: Total file size
66 # CHECK-NEXT: [[#%u, LINKEDIT_OFF + LINKEDIT_SIZE]]
73 .section maxlen_16ch_name,foo