xref: /llvm-project/lld/test/ELF/ctors_dtors_priority.s (revision a7f9c002cd2e8053a06667923d2b5d45d4b9d947)
1// REQUIRES: x86
2
3// Test .ctors* and .dtors* are sorted by priority.
4
5// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1
6// RUN: rm -rf %t && mkdir -p %t
7// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
8// RUN:   %p/Inputs/ctors_dtors_priority1.s -o %t/crtbegin.o
9// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
10// RUN:   %p/Inputs/ctors_dtors_priority2.s -o %t2
11// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
12// RUN:   %p/Inputs/ctors_dtors_priority3.s -o %t/crtend.o
13// RUN: ld.lld %t1 %t2 %t/crtend.o %t/crtbegin.o -o %t.exe
14// RUN: llvm-objdump -s %t.exe | FileCheck %s
15
16// RUN: cp %t/crtbegin.o %t/clang_rt.crtbegin.o
17// RUN: cp %t/crtend.o %t/clang_rt.crtend.o
18// RUN: ld.lld %t1 %t2 %t/clang_rt.crtend.o %t/clang_rt.crtbegin.o -o %t.clang_rt.exe
19// RUN: llvm-objdump -s %t.clang_rt.exe | FileCheck %s
20
21// RUN: cp %t/crtbegin.o %t/clang_rt.crtbegin-x86_64.o
22// RUN: cp %t/crtend.o %t/clang_rt.crtend-x86_64.o
23// RUN: ld.lld %t1 %t2 %t/clang_rt.crtend-x86_64.o %t/clang_rt.crtbegin-x86_64.o -o %t.clang_rt-arch.exe
24// RUN: llvm-objdump -s %t.clang_rt-arch.exe | FileCheck %s
25
26// RUN: cp %t/crtbegin.o %t/crtbeginS.o
27// RUN: cp %t/crtend.o %t/crtendT.o
28// RUN: ld.lld %t1 %t2 %t/crtendT.o %t/crtbeginS.o -o %t.ST.exe
29// RUN: cmp %t.exe %t.ST.exe
30
31.globl _start
32_start:
33  nop
34
35.section .ctors, "aw", @progbits
36  .quad 1
37.section .ctors.100, "aw", @progbits
38  .quad 2
39.section .ctors.005, "aw", @progbits
40  .quad 3
41.section .ctors, "aw", @progbits
42  .quad 4
43.section .ctors, "aw", @progbits
44  .quad 5
45
46.section .dtors, "aw", @progbits
47  .quad 0x11
48.section .dtors.100, "aw", @progbits
49  .quad 0x12
50.section .dtors.005, "aw", @progbits
51  .quad 0x13
52.section .dtors, "aw", @progbits
53  .quad 0x14
54.section .dtors, "aw", @progbits
55  .quad 0x15
56
57// CHECK:      Contents of section .ctors:
58// CHECK-NEXT:        a1000000 00000000 01000000 00000000
59// CHECK-NEXT:        04000000 00000000 05000000 00000000
60// CHECK-NEXT:        b1000000 00000000 03000000 00000000
61// CHECK-NEXT:        02000000 00000000 c1000000 00000000
62
63// CHECK:      Contents of section .dtors:
64// CHECK-NEXT:        a2000000 00000000 11000000 00000000
65// CHECK-NEXT:        14000000 00000000 15000000 00000000
66// CHECK-NEXT:        b2000000 00000000 13000000 00000000
67// CHECK-NEXT:        12000000 00000000 c2000000 00000000
68