[clang-tidy][modernize-use-starts-ends-with] Fix operator rewriting false negative...
[llvm-project.git] / lld / test / ELF / symbol-ordering-file.s
blob8ed35738ad56b2403444f2a354ef01313fdfd9fa
1 # REQUIRES: x86
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:
9 # BEFORE-NEXT: 1122
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:
40 # AFTER-NEXT: 1122
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
49 ## normal order).
50 # RUN: touch %t.empty
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
55 _foo1:
56 .byte 0x11
58 .section .foo,"ax",@progbits,unique,2
59 _foo2:
60 .byte 0x22
62 .section .foo,"ax",@progbits,unique,3
63 _foo3:
64 .byte 0x33
66 .section .foo,"ax",@progbits,unique,4
67 _foo4:
68 .byte 0x44
70 .section .foo,"ax",@progbits,unique,5
71 _foo5:
72 .byte 0x55
73 _bar1:
74 .byte 0x66
76 .section .foo,"ax",@progbits,unique,6
77 "_nönascii":
78 .byte 0x77
80 .section .init,"ax",@progbits,unique,1
81 _init1:
82 .byte 0x11
84 .section .init,"ax",@progbits,unique,2
85 _init2:
86 .byte 0x22
88 .text
89 .global _start
90 _start:
91 nop