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 5 6# BEFORE: Contents of section .foo: 7# BEFORE-NEXT: 11223344 556677 8# BEFORE: Contents of section .init: 9# BEFORE-NEXT: 1122 10 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 24 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 34 35# WARN: warning: {{.*}}.txt: duplicate ordered symbol 36 37# AFTER: Contents of section .foo: 38# AFTER-NEXT: 44337755 662211 39# AFTER: Contents of section .init: 40# AFTER-NEXT: 1122 41 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 %s --check-prefix=ERR -DFILE=%t.nonexistent 45 46# ERR: error: cannot open [[FILE]]: {{[Nn]}}o such file or directory 47 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 53 54.section .foo,"ax",@progbits,unique,1 55_foo1: 56 .byte 0x11 57 58.section .foo,"ax",@progbits,unique,2 59_foo2: 60 .byte 0x22 61 62.section .foo,"ax",@progbits,unique,3 63_foo3: 64 .byte 0x33 65 66.section .foo,"ax",@progbits,unique,4 67_foo4: 68 .byte 0x44 69 70.section .foo,"ax",@progbits,unique,5 71_foo5: 72 .byte 0x55 73_bar1: 74 .byte 0x66 75 76.section .foo,"ax",@progbits,unique,6 77"_nönascii": 78.byte 0x77 79 80.section .init,"ax",@progbits,unique,1 81_init1: 82 .byte 0x11 83 84.section .init,"ax",@progbits,unique,2 85_init2: 86 .byte 0x22 87 88.text 89.global _start 90_start: 91 nop 92