File: ctors_dtors_priority.s

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (67 lines) | stat: -rw-r--r-- 2,353 bytes parent folder | download | duplicates (18)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// REQUIRES: x86

// Test .ctors* and .dtors* are sorted by priority.

// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1
// RUN: rm -rf %t && mkdir -p %t
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
// RUN:   %p/Inputs/ctors_dtors_priority1.s -o %t/crtbegin.o
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
// RUN:   %p/Inputs/ctors_dtors_priority2.s -o %t2
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
// RUN:   %p/Inputs/ctors_dtors_priority3.s -o %t/crtend.o
// RUN: ld.lld %t1 %t2 %t/crtend.o %t/crtbegin.o -o %t.exe
// RUN: llvm-objdump -s %t.exe | FileCheck %s

// RUN: cp %t/crtbegin.o %t/clang_rt.crtbegin.o
// RUN: cp %t/crtend.o %t/clang_rt.crtend.o
// RUN: ld.lld %t1 %t2 %t/clang_rt.crtend.o %t/clang_rt.crtbegin.o -o %t.clang_rt.exe
// RUN: llvm-objdump -s %t.clang_rt.exe | FileCheck %s

// RUN: cp %t/crtbegin.o %t/clang_rt.crtbegin-x86_64.o
// RUN: cp %t/crtend.o %t/clang_rt.crtend-x86_64.o
// 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
// RUN: llvm-objdump -s %t.clang_rt-arch.exe | FileCheck %s

// RUN: cp %t/crtbegin.o %t/crtbeginS.o
// RUN: cp %t/crtend.o %t/crtendT.o
// RUN: ld.lld %t1 %t2 %t/crtendT.o %t/crtbeginS.o -o %t.ST.exe
// RUN: cmp %t.exe %t.ST.exe
	
.globl _start
_start:
  nop

.section .ctors, "aw", @progbits
  .quad 1
.section .ctors.100, "aw", @progbits
  .quad 2
.section .ctors.005, "aw", @progbits
  .quad 3
.section .ctors, "aw", @progbits
  .quad 4
.section .ctors, "aw", @progbits
  .quad 5

.section .dtors, "aw", @progbits
  .quad 0x11
.section .dtors.100, "aw", @progbits
  .quad 0x12
.section .dtors.005, "aw", @progbits
  .quad 0x13
.section .dtors, "aw", @progbits
  .quad 0x14
.section .dtors, "aw", @progbits
  .quad 0x15

// CHECK:      Contents of section .ctors:
// CHECK-NEXT:        a1000000 00000000 01000000 00000000
// CHECK-NEXT:        04000000 00000000 05000000 00000000
// CHECK-NEXT:        b1000000 00000000 03000000 00000000
// CHECK-NEXT:        02000000 00000000 c1000000 00000000

// CHECK:      Contents of section .dtors:
// CHECK-NEXT:        a2000000 00000000 11000000 00000000
// CHECK-NEXT:        14000000 00000000 15000000 00000000
// CHECK-NEXT:        b2000000 00000000 13000000 00000000
// CHECK-NEXT:        12000000 00000000 c2000000 00000000