2 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o
4 ## Make sure the option parser doesn't think --x and -w are flags.
5 # RUN: %lld -dylib -o %t %t.o \
6 # RUN: -segprot FOO rwx xwr \
7 # RUN: -segprot BAR --x --x \
8 # RUN: -segprot BAZ -w -w
9 # RUN: llvm-readobj --macho-segment %t | FileCheck %s
15 # CHECK-NEXT: fileoff:
16 # CHECK-NEXT: filesize:
17 # CHECK-NEXT: maxprot: rwx
18 # CHECK-NEXT: initprot: rwx
24 # CHECK-NEXT: fileoff:
25 # CHECK-NEXT: filesize:
26 # CHECK-NEXT: maxprot: --x
27 # CHECK-NEXT: initprot: --x
33 # CHECK-NEXT: fileoff:
34 # CHECK-NEXT: filesize:
35 # CHECK-NEXT: maxprot: -w-
36 # CHECK-NEXT: initprot: -w-
38 # RUN: %lld -dylib -o %t.different %t.o -segprot FOO rw r
39 # RUN: llvm-readobj --macho-segment %t.different \
40 # RUN: | FileCheck %s --check-prefix=DIFFERENT
42 # RUN: %no-arg-lld -arch x86_64 -platform_version "mac catalyst" 14.0.0 17.5 \
43 # RUN: -dylib -o /dev/null %t.o -segprot FOO rw r
44 # RUN: llvm-readobj --macho-segment %t.different \
45 # RUN: | FileCheck %s --check-prefix=DIFFERENT
47 # DIFFERENT: Name: FOO
48 # DIFFERENT-NEXT: Size:
49 # DIFFERENT-NEXT: vmaddr:
50 # DIFFERENT-NEXT: vmsize:
51 # DIFFERENT-NEXT: fileoff:
52 # DIFFERENT-NEXT: filesize:
53 # DIFFERENT-NEXT: maxprot: rw-
54 # DIFFERENT-NEXT: initprot: r--
56 # RUN: not %no-arg-lld -arch x86_64 -platform_version ios-simulator 14.0 15.0 \
57 # RUN: -dylib -o /dev/null %t.o -segprot FOO rwx rw 2>&1 \
58 # RUN: | FileCheck %s --check-prefix=MISMATCH
59 # RUN: not %lld -dylib -o /dev/null %t.o -segprot FOO r rw 2>&1 \
60 # RUN: | FileCheck %s --check-prefix=INITTOOPERMISSIVE
61 # RUN: not %lld -dylib -o /dev/null %t.o -segprot __LINKEDIT rwx rwx 2>&1 \
62 # RUN: | FileCheck %s --check-prefix=NO-LINKEDIT
63 # RUN: not %lld -dylib -o /dev/null %t.o -segprot FOO uhh wat 2>&1 \
64 # RUN: | FileCheck %s --check-prefix=MISPARSE
65 # RUN: not %lld -dylib -o /dev/null %t.o -segprot FOO rwx 2>&1 \
66 # RUN: | FileCheck %s --check-prefix=MISSING
68 # MISMATCH: error: invalid argument '-segprot FOO rwx rw': max and init must be the same for non-macOS non-i386 archs
69 # INITTOOPERMISSIVE: error: invalid argument '-segprot FOO r rw': init must not be more permissive than max
70 # NO-LINKEDIT: error: -segprot cannot be used to change __LINKEDIT's protections
71 # MISPARSE: error: unknown -segprot letter 'u' in uhh
72 # MISPARSE: error: unknown -segprot letter 'a' in wat
73 # MISSING: error: -segprot: missing argument