2 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
3 # RUN: ld.lld %t.o -o %t.out
4 # RUN: llvm-objdump -s %t.out| FileCheck %s --check-prefix=BEFORE
6 # BEFORE: Contents of section .foo:
7 # BEFORE-NEXT: 11223344 556677
8 # BEFORE: Contents of section .init:
11 # RUN: echo "_foo4 " > %t_order.txt
12 # RUN: echo " _foo3" >> %t_order.txt
13 # RUN: echo "_nönascii" >> %t_order.txt
14 # RUN: echo "_foo5" >> %t_order.txt
15 # RUN: echo -e " _foo2 \t\v\r\f" >> %t_order.txt
16 # RUN: echo "# a comment" >> %t_order.txt
17 # RUN: echo " " >> %t_order.txt
18 # RUN: echo "_foo4" >> %t_order.txt
19 # RUN: echo "_bar1" >> %t_order.txt
20 # RUN: echo "" >> %t_order.txt
21 # RUN: echo "_foo1" >> %t_order.txt
22 # RUN: echo "_init2" >> %t_order.txt
23 # RUN: echo "_init1" >> %t_order.txt
25 ## Show that both --symbol-ordering-file and --symbol-ordering-file= work.
26 ## Also show that lines beginning with '#', whitespace and empty lines, are ignored.
27 ## Also show that "first one wins" when there are duplicate symbols in the order
28 ## file (a warning will be emitted).
29 # RUN: ld.lld --symbol-ordering-file %t_order.txt %t.o -o %t2.out 2>&1 | \
30 # RUN: FileCheck %s --check-prefix=WARN --implicit-check-not=warning:
31 # RUN: llvm-objdump -s %t2.out | FileCheck %s --check-prefix=AFTER
32 # RUN: ld.lld --symbol-ordering-file=%t_order.txt %t.o -o %t2.out
33 # RUN: llvm-objdump -s %t2.out | FileCheck %s --check-prefix=AFTER
35 # WARN: warning: {{.*}}.txt: duplicate ordered symbol
37 # AFTER: Contents of section .foo:
38 # AFTER-NEXT: 44337755 662211
39 # AFTER: Contents of section .init:
42 ## Show that a nonexistent symbol ordering file causes an error.
43 # RUN: not ld.lld --symbol-ordering-file=%t.nonexistent %t.o -o %t3.out 2>&1 | \
44 # RUN: FileCheck -DMSG=%errc_ENOENT %s --check-prefix=ERR -DFILE=%t.nonexistent
46 # ERR: error: cannot open [[FILE]]: [[MSG]]
48 ## Show that an empty ordering file can be handled (symbols remain in their
51 # RUN: ld.lld --symbol-ordering-file=%t.empty %t.o -o %t4.out
52 # RUN: llvm-objdump -s %t4.out | FileCheck %s --check-prefix=BEFORE
54 .section .foo,"ax",@progbits,unique,1
58 .section .foo,"ax",@progbits,unique,2
62 .section .foo,"ax",@progbits,unique,3
66 .section .foo,"ax",@progbits,unique,4
70 .section .foo,"ax",@progbits,unique,5
76 .section .foo,"ax",@progbits,unique,6
80 .section .init,"ax",@progbits,unique,1
84 .section .init,"ax",@progbits,unique,2