1# REQUIRES: x86 2# RUN: rm -rf %t; split-file %s %t 3# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o 4# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o 5# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/abs.s -o %t/abs.o 6# RUN: llvm-ar rcs %t/foo.a %t/foo.o 7 8# FOO-FIRST: <_bar>: 9# FOO-FIRST: <_main>: 10 11# FOO-SECOND: <_main>: 12# FOO-SECOND: <_bar>: 13 14# RUN: %lld -lSystem -o %t/test-1 %t/test.o %t/foo.o -order_file %t/ord-1 15# RUN: llvm-objdump -d %t/test-1 | FileCheck %s --check-prefix=FOO-FIRST 16## Output should be the same regardless of the command-line order of object files 17# RUN: %lld -lSystem -o %t/test-1 %t/foo.o %t/test.o -order_file %t/ord-1 18# RUN: llvm-objdump -d %t/test-1 | FileCheck %s --check-prefix=FOO-FIRST 19 20# RUN: %lld -lSystem -o %t/test-2 %t/test.o %t/foo.o -order_file %t/ord-2 21# RUN: llvm-objdump -d %t/test-2 | FileCheck %s --check-prefix=FOO-SECOND 22# RUN: %lld -lSystem -o %t/test-2 %t/foo.o %t/test.o -order_file %t/ord-2 23# RUN: llvm-objdump -d %t/test-2 | FileCheck %s --check-prefix=FOO-SECOND 24 25# RUN: %lld -lSystem -o %t/test-file-match %t/test.o %t/foo.o -order_file %t/ord-file-match 26# RUN: llvm-objdump -d %t/test-file-match | FileCheck %s --check-prefix=FOO-FIRST 27## Output should be the same regardless of the command-line order of object files 28# RUN: %lld -lSystem -o %t/test-file-match %t/foo.o %t/test.o -order_file %t/ord-file-match 29# RUN: llvm-objdump -d %t/test-file-match | FileCheck %s --check-prefix=FOO-FIRST 30 31# RUN: %lld -lSystem -o %t/test-file-nomatch %t/test.o %t/foo.o -order_file %t/ord-file-nomatch 32# RUN: llvm-objdump -d %t/test-file-nomatch | FileCheck %s --check-prefix=FOO-SECOND 33# RUN: %lld -lSystem -o %t/test-file-nomatch %t/foo.o %t/test.o -order_file %t/ord-file-nomatch 34# RUN: llvm-objdump -d %t/test-file-nomatch | FileCheck %s --check-prefix=FOO-SECOND 35 36# RUN: %lld -lSystem -o %t/test-arch-match %t/test.o %t/foo.o -order_file %t/ord-arch-match 37# RUN: llvm-objdump -d %t/test-arch-match | FileCheck %s --check-prefix=FOO-FIRST 38# RUN: %lld -lSystem -o %t/test-arch-match %t/foo.o %t/test.o -order_file %t/ord-arch-match 39# RUN: llvm-objdump -d %t/test-arch-match | FileCheck %s --check-prefix=FOO-FIRST 40 41# RUN: %lld -lSystem -o %t/test-arch-nomatch %t/test.o %t/foo.o -order_file %t/ord-arch-nomatch 42# RUN: llvm-objdump -d %t/test-arch-nomatch | FileCheck %s --check-prefix=FOO-SECOND 43# RUN: %lld -lSystem -o %t/test-arch-nomatch %t/foo.o %t/test.o -order_file %t/ord-arch-nomatch 44# RUN: llvm-objdump -d %t/test-arch-nomatch | FileCheck %s --check-prefix=FOO-SECOND 45 46# RUN: %lld -lSystem -o %t/test-arch-match %t/test.o %t/foo.o -order_file %t/ord-arch-match 47# RUN: llvm-objdump -d %t/test-arch-match | FileCheck %s --check-prefix=FOO-FIRST 48# RUN: %lld -lSystem -o %t/test-arch-match %t/foo.o %t/test.o -order_file %t/ord-arch-match 49# RUN: llvm-objdump -d %t/test-arch-match | FileCheck %s --check-prefix=FOO-FIRST 50 51## Test archives 52 53# RUN: %lld -lSystem -o %t/test-archive-1 %t/test.o %t/foo.a -order_file %t/ord-1 54# RUN: llvm-objdump -d %t/test-archive-1 | FileCheck %s --check-prefix=FOO-FIRST 55# RUN: %lld -lSystem -o %t/test-archive-1 %t/foo.a %t/test.o -order_file %t/ord-1 56# RUN: llvm-objdump -d %t/test-archive-1 | FileCheck %s --check-prefix=FOO-FIRST 57 58# RUN: %lld -lSystem -o %t/test-archive-file-no-match %t/test.o %t/foo.a -order_file %t/ord-file-match 59# RUN: llvm-objdump -d %t/test-archive-file-no-match | FileCheck %s --check-prefix=FOO-SECOND 60# RUN: %lld -lSystem -o %t/test-archive %t/foo.a %t/test.o -order_file %t/ord-file-match 61# RUN: llvm-objdump -d %t/test-archive-file-no-match | FileCheck %s --check-prefix=FOO-SECOND 62 63# RUN: %lld -lSystem -o %t/test-archive-1 %t/test.o %t/foo.a -order_file %t/ord-archive-match 64# RUN: llvm-objdump -d %t/test-archive-1 | FileCheck %s --check-prefix=FOO-FIRST 65# RUN: %lld -lSystem -o %t/test-archive-1 %t/foo.a %t/test.o -order_file %t/ord-archive-match 66# RUN: llvm-objdump -d %t/test-archive-1 | FileCheck %s --check-prefix=FOO-FIRST 67 68# RUN: %lld -lSystem -o %t/test-archive-file-no-match %t/test.o %t/foo.a -order_file %t/ord-file-nomatch 69# RUN: llvm-objdump -d %t/test-archive-file-no-match | FileCheck %s --check-prefix=FOO-SECOND 70# RUN: %lld -lSystem -o %t/test-archive %t/foo.a %t/test.o -order_file %t/ord-file-nomatch 71# RUN: llvm-objdump -d %t/test-archive-file-no-match | FileCheck %s --check-prefix=FOO-SECOND 72 73## The following tests check that if an address is matched by multiple order 74## file entries, it should always use the lowest-ordered match. 75 76# RUN: %lld -lSystem -o %t/test-1 %t/test.o %t/foo.o -order_file %t/ord-multiple-1 77# RUN: llvm-objdump -d %t/test-1 | FileCheck %s --check-prefix=FOO-FIRST 78# RUN: %lld -lSystem -o %t/test-1 %t/foo.o %t/test.o -order_file %t/ord-multiple-1 79# RUN: llvm-objdump -d %t/test-1 | FileCheck %s --check-prefix=FOO-FIRST 80 81# RUN: %lld -lSystem -o %t/test-2 %t/test.o %t/foo.o -order_file %t/ord-multiple-2 82# RUN: llvm-objdump -d %t/test-2 | FileCheck %s --check-prefix=FOO-FIRST 83# RUN: %lld -lSystem -o %t/test-2 %t/foo.o %t/test.o -order_file %t/ord-multiple-2 84# RUN: llvm-objdump -d %t/test-2 | FileCheck %s --check-prefix=FOO-FIRST 85 86# RUN: %lld -lSystem -o %t/test-3 %t/test.o %t/foo.o -order_file %t/ord-multiple-3 87# RUN: llvm-objdump -d %t/test-3 | FileCheck %s --check-prefix=FOO-FIRST 88# RUN: %lld -lSystem -o %t/test-3 %t/foo.o %t/test.o -order_file %t/ord-multiple-3 89# RUN: llvm-objdump -d %t/test-3 | FileCheck %s --check-prefix=FOO-FIRST 90 91# RUN: %lld -lSystem -o %t/test-4 %t/test.o %t/foo.o -order_file %t/ord-multiple-4 92# RUN: llvm-objdump -d %t/test-4 | FileCheck %s --check-prefix=FOO-FIRST 93# RUN: %lld -lSystem -o %t/test-4 %t/foo.o %t/test.o -order_file %t/ord-multiple-4 94# RUN: llvm-objdump -d %t/test-4 | FileCheck %s --check-prefix=FOO-FIRST 95 96## -[Foo doFoo:andBar:] and _bar both point to the same location. When both 97## symbols appear in an order file, the location in question should be ordered 98## according to the lowest-ordered symbol that references it. 99 100# RUN: %lld -lSystem -o %t/test-alias %t/test.o %t/foo.o -order_file %t/ord-alias 101# RUN: llvm-objdump -d %t/test-alias | FileCheck %s --check-prefix=FOO-FIRST 102# RUN: %lld -lSystem -o %t/test-alias %t/foo.o %t/test.o -order_file %t/ord-alias 103# RUN: llvm-objdump -d %t/test-alias | FileCheck %s --check-prefix=FOO-FIRST 104 105## Absolute in symbols in order files make no sense. Just ignore them. 106# RUN: %lld -lSystem -dylib -o %t/test-abs %t/abs.o -order_file %t/ord-abs 107 108#--- ord-1 109-[Foo doFoo:andBar:] # just a comment 110_main # another comment 111 112#--- ord-2 113_main # just a comment 114-[Foo doFoo:andBar:] # another comment 115 116#--- ord-file-match 117foo.o:-[Foo doFoo:andBar:] 118_main 119 120#--- ord-archive-match 121foo.a(foo.o):-[Foo doFoo:andBar:] 122_main 123 124#--- ord-file-nomatch 125bar.o:-[Foo doFoo:andBar:] 126_main 127-[Foo doFoo:andBar:] 128 129#--- ord-arch-match 130x86_64:-[Foo doFoo:andBar:] 131_main 132 133#--- ord-arch-nomatch 134arm64:-[Foo doFoo:andBar:] 135_main 136-[Foo doFoo:andBar:] 137 138#--- ord-arch-file-match 139x86_64:bar.o:-[Foo doFoo:andBar:] 140_main 141 142#--- ord-multiple-1 143-[Foo doFoo:andBar:] 144_main 145foo.o:-[Foo doFoo:andBar:] 146 147#--- ord-multiple-2 148foo.o:-[Foo doFoo:andBar:] 149_main 150-[Foo doFoo:andBar:] 151 152#--- ord-multiple-3 153-[Foo doFoo:andBar:] 154_main 155-[Foo doFoo:andBar:] 156 157#--- ord-multiple-4 158foo.o:-[Foo doFoo:andBar:] 159_main 160foo.o:-[Foo doFoo:andBar:] 161 162#--- ord-alias 163_bar 164_main 165-[Foo doFoo:andBar:] 166 167#--- ord-abs 168_abs 169 170#--- foo.s 171.globl "-[Foo doFoo:andBar:]" 172"-[Foo doFoo:andBar:]": 173_bar: 174 ret 175 176#--- test.s 177.globl _main 178 179_main: 180 callq "-[Foo doFoo:andBar:]" 181 ret 182 183.section __DWARF,__debug_aranges,regular,debug 184ltmp1: 185 .byte 0 186 187#--- abs.s 188_abs = 42 189