• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# REQUIRES: x86
2# RUN: mkdir -p %t
3# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t/test.o
4# RUN: echo ".globl _foo; .text; _foo: _bar: ret" | \
5# RUN:   llvm-mc -filetype=obj -triple=x86_64-apple-darwin -o %t/foo.o
6# RUN: rm -f %t/foo.a
7# RUN: llvm-ar rcs %t/foo.a %t/foo.o
8
9# FOO-FIRST: <_foo>:
10# FOO-FIRST: <_main>:
11
12# FOO-SECOND: <_main>:
13# FOO-SECOND: <_foo>:
14
15# RUN: echo "_foo # just a comment" > %t/ord-1
16# RUN: echo "_main # another comment" >> %t/ord-1
17# RUN: %lld -o %t/test-1 %t/test.o %t/foo.o -order_file %t/ord-1
18# RUN: llvm-objdump -d %t/test-1 | FileCheck %s --check-prefix=FOO-FIRST
19## Output should be the same regardless of the command-line order of object files
20# RUN: %lld -o %t/test-1 %t/foo.o %t/test.o -order_file %t/ord-1
21# RUN: llvm-objdump -d %t/test-1 | FileCheck %s --check-prefix=FOO-FIRST
22
23# RUN: echo "_main # just a comment" > %t/ord-2
24# RUN: echo "_foo # another comment" >> %t/ord-2
25# RUN: %lld -o %t/test-2 %t/test.o %t/foo.o -order_file %t/ord-2
26# RUN: llvm-objdump -d %t/test-2 | FileCheck %s --check-prefix=FOO-SECOND
27# RUN: %lld -o %t/test-2 %t/foo.o %t/test.o -order_file %t/ord-2
28# RUN: llvm-objdump -d %t/test-2 | FileCheck %s --check-prefix=FOO-SECOND
29
30# RUN: echo "foo.o:_foo" > %t/ord-file-match
31# RUN: echo "_main" >> %t/ord-file-match
32# RUN: %lld -o %t/test-file-match %t/test.o %t/foo.o -order_file %t/ord-file-match
33# RUN: llvm-objdump -d %t/test-file-match | FileCheck %s --check-prefix=FOO-FIRST
34## Output should be the same regardless of the command-line order of object files
35# RUN: %lld -o %t/test-file-match %t/foo.o %t/test.o -order_file %t/ord-file-match
36# RUN: llvm-objdump -d %t/test-file-match | FileCheck %s --check-prefix=FOO-FIRST
37
38# RUN: echo "bar.o:_foo" > %t/ord-file-nomatch
39# RUN: echo "_main" >> %t/ord-file-nomatch
40# RUN: echo "_foo" >> %t/ord-file-nomatch
41# RUN: %lld -o %t/test-file-nomatch %t/test.o %t/foo.o -order_file %t/ord-file-nomatch
42# RUN: llvm-objdump -d %t/test-file-nomatch | FileCheck %s --check-prefix=FOO-SECOND
43# RUN: %lld -o %t/test-file-nomatch %t/foo.o %t/test.o -order_file %t/ord-file-nomatch
44# RUN: llvm-objdump -d %t/test-file-nomatch | FileCheck %s --check-prefix=FOO-SECOND
45
46# RUN: echo "x86_64:_foo" > %t/ord-arch-match
47# RUN: echo "_main" >> %t/ord-arch-match
48# RUN: %lld -o %t/test-arch-match %t/test.o %t/foo.o -order_file %t/ord-arch-match
49# RUN: llvm-objdump -d %t/test-arch-match | FileCheck %s --check-prefix=FOO-FIRST
50# RUN: %lld -o %t/test-arch-match %t/foo.o %t/test.o -order_file %t/ord-arch-match
51# RUN: llvm-objdump -d %t/test-arch-match | FileCheck %s --check-prefix=FOO-FIRST
52
53# RUN: echo "ppc:_foo" > %t/ord-arch-nomatch
54# RUN: echo "_main" >> %t/ord-arch-nomatch
55# RUN: echo "_foo" >> %t/ord-arch-nomatch
56# RUN: %lld -o %t/test-arch-nomatch %t/test.o %t/foo.o -order_file %t/ord-arch-nomatch
57# RUN: llvm-objdump -d %t/test-arch-nomatch | FileCheck %s --check-prefix=FOO-SECOND
58# RUN: %lld -o %t/test-arch-nomatch %t/foo.o %t/test.o -order_file %t/ord-arch-nomatch
59# RUN: llvm-objdump -d %t/test-arch-nomatch | FileCheck %s --check-prefix=FOO-SECOND
60
61# RUN: echo "x86_64:bar.o:_foo" > %t/ord-arch-file-match
62# RUN: echo "_main" >> %t/ord-arch-match
63# RUN: %lld -o %t/test-arch-match %t/test.o %t/foo.o -order_file %t/ord-arch-match
64# RUN: llvm-objdump -d %t/test-arch-match | FileCheck %s --check-prefix=FOO-FIRST
65# RUN: %lld -o %t/test-arch-match %t/foo.o %t/test.o -order_file %t/ord-arch-match
66# RUN: llvm-objdump -d %t/test-arch-match | FileCheck %s --check-prefix=FOO-FIRST
67
68## Test archives
69
70# RUN: %lld -o %t/test-archive-1 %t/test.o %t/foo.a -order_file %t/ord-1
71# RUN: llvm-objdump -d %t/test-archive-1 | FileCheck %s --check-prefix=FOO-FIRST
72# RUN: %lld -o %t/test-archive-1 %t/foo.a %t/test.o -order_file %t/ord-1
73# RUN: llvm-objdump -d %t/test-archive-1 | FileCheck %s --check-prefix=FOO-FIRST
74
75# RUN: %lld -o %t/test-archive-file-no-match %t/test.o %t/foo.a -order_file %t/ord-file-nomatch
76# RUN: llvm-objdump -d %t/test-archive-file-no-match | FileCheck %s --check-prefix=FOO-SECOND
77# RUN: %lld -o %t/test-archive %t/foo.a %t/test.o -order_file %t/ord-file-nomatch
78# RUN: llvm-objdump -d %t/test-archive-file-no-match | FileCheck %s --check-prefix=FOO-SECOND
79
80## The following tests check that if an address is matched by multiple order
81## file entries, it should always use the lowest-ordered match.
82
83# RUN: echo "_foo" > %t/ord-multiple-1
84# RUN: echo "_main" >> %t/ord-multiple-1
85# RUN: echo "foo.o:_foo" >> %t/ord-multiple-1
86# RUN: %lld -o %t/test-1 %t/test.o %t/foo.o -order_file %t/ord-multiple-1
87# RUN: llvm-objdump -d %t/test-1 | FileCheck %s --check-prefix=FOO-FIRST
88# RUN: %lld -o %t/test-1 %t/foo.o %t/test.o -order_file %t/ord-multiple-1
89# RUN: llvm-objdump -d %t/test-1 | FileCheck %s --check-prefix=FOO-FIRST
90
91# RUN: echo "foo.o:_foo" > %t/ord-multiple-2
92# RUN: echo "_main" >> %t/ord-multiple-2
93# RUN: echo "_foo" >> %t/ord-multiple-2
94# RUN: %lld -o %t/test-2 %t/test.o %t/foo.o -order_file %t/ord-multiple-2
95# RUN: llvm-objdump -d %t/test-2 | FileCheck %s --check-prefix=FOO-FIRST
96# RUN: %lld -o %t/test-2 %t/foo.o %t/test.o -order_file %t/ord-multiple-2
97# RUN: llvm-objdump -d %t/test-2 | FileCheck %s --check-prefix=FOO-FIRST
98
99# RUN: echo "_foo" > %t/ord-multiple-3
100# RUN: echo "_main" >> %t/ord-multiple-3
101# RUN: echo "_foo" >> %t/ord-multiple-3
102# RUN: %lld -o %t/test-3 %t/test.o %t/foo.o -order_file %t/ord-multiple-3
103# RUN: llvm-objdump -d %t/test-3 | FileCheck %s --check-prefix=FOO-FIRST
104# RUN: %lld -o %t/test-3 %t/foo.o %t/test.o -order_file %t/ord-multiple-3
105# RUN: llvm-objdump -d %t/test-3 | FileCheck %s --check-prefix=FOO-FIRST
106
107# RUN: echo "foo.o:_foo" > %t/ord-multiple-4
108# RUN: echo "_main" >> %t/ord-multiple-4
109# RUN: echo "foo.o:_foo" >> %t/ord-multiple-4
110# RUN: %lld -o %t/test-4 %t/test.o %t/foo.o -order_file %t/ord-multiple-4
111# RUN: llvm-objdump -d %t/test-4 | FileCheck %s --check-prefix=FOO-FIRST
112# RUN: %lld -o %t/test-4 %t/foo.o %t/test.o -order_file %t/ord-multiple-4
113# RUN: llvm-objdump -d %t/test-4 | FileCheck %s --check-prefix=FOO-FIRST
114
115## _foo and _bar both point to the same location. When both symbols appear in
116## an order file, the location in question should be ordered according to the
117## lowest-ordered symbol that references it.
118# RUN: echo "_bar" > %t/ord-alias
119# RUN: echo "_main" >> %t/ord-alias
120# RUN: echo "_foo" >> %t/ord-alias
121# RUN: %lld -o %t/test-alias %t/test.o %t/foo.o -order_file %t/ord-alias
122# RUN: llvm-objdump -d %t/test-alias | FileCheck %s --check-prefix=FOO-FIRST
123# RUN: %lld -o %t/test-alias %t/foo.o %t/test.o -order_file %t/ord-alias
124# RUN: llvm-objdump -d %t/test-alias | FileCheck %s --check-prefix=FOO-FIRST
125
126.text
127.globl _main
128
129_main:
130  callq _foo
131  ret
132