2018-06-27 06:20:04 +08:00
|
|
|
// REQUIRES: x86
|
2019-09-06 23:10:31 +08:00
|
|
|
|
|
|
|
// Test .ctors* and .dtors* are sorted by priority.
|
|
|
|
|
2016-02-12 07:41:38 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1
|
2019-10-26 02:04:56 +08:00
|
|
|
// RUN: mkdir -p %t
|
2016-02-12 07:41:38 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \
|
2019-10-26 02:04:56 +08:00
|
|
|
// RUN: %p/Inputs/ctors_dtors_priority1.s -o %t/crtbegin.o
|
2016-02-12 07:41:38 +08:00
|
|
|
// 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 \
|
2019-10-26 02:04:56 +08:00
|
|
|
// 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
|
2016-02-11 09:07:19 +08:00
|
|
|
// RUN: llvm-objdump -s %t.exe | FileCheck %s
|
|
|
|
|
2019-10-26 02:04:56 +08:00
|
|
|
// 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
|
|
|
|
|
|
|
|
|
2016-02-11 09:07:19 +08:00
|
|
|
.globl _start
|
|
|
|
_start:
|
|
|
|
nop
|
|
|
|
|
|
|
|
.section .ctors, "aw", @progbits
|
2017-07-18 04:42:52 +08:00
|
|
|
.quad 1
|
2016-02-11 09:07:19 +08:00
|
|
|
.section .ctors.100, "aw", @progbits
|
2017-07-18 04:42:52 +08:00
|
|
|
.quad 2
|
2016-02-12 07:41:38 +08:00
|
|
|
.section .ctors.005, "aw", @progbits
|
2017-07-18 04:42:52 +08:00
|
|
|
.quad 3
|
2016-02-11 09:07:19 +08:00
|
|
|
.section .ctors, "aw", @progbits
|
2017-07-18 04:42:52 +08:00
|
|
|
.quad 4
|
2016-02-11 09:07:19 +08:00
|
|
|
.section .ctors, "aw", @progbits
|
2017-07-18 04:42:52 +08:00
|
|
|
.quad 5
|
2016-02-11 09:07:19 +08:00
|
|
|
|
|
|
|
.section .dtors, "aw", @progbits
|
2017-07-18 04:42:52 +08:00
|
|
|
.quad 0x11
|
2016-02-11 09:07:19 +08:00
|
|
|
.section .dtors.100, "aw", @progbits
|
2017-07-18 04:42:52 +08:00
|
|
|
.quad 0x12
|
2016-02-12 07:41:38 +08:00
|
|
|
.section .dtors.005, "aw", @progbits
|
2017-07-18 04:42:52 +08:00
|
|
|
.quad 0x13
|
2016-02-11 09:07:19 +08:00
|
|
|
.section .dtors, "aw", @progbits
|
2017-07-18 04:42:52 +08:00
|
|
|
.quad 0x14
|
2016-02-11 09:07:19 +08:00
|
|
|
.section .dtors, "aw", @progbits
|
2017-07-18 04:42:52 +08:00
|
|
|
.quad 0x15
|
2016-02-11 09:07:19 +08:00
|
|
|
|
|
|
|
// CHECK: Contents of section .ctors:
|
2019-09-06 23:10:31 +08:00
|
|
|
// CHECK-NEXT: a1000000 00000000 01000000 00000000
|
|
|
|
// CHECK-NEXT: 04000000 00000000 05000000 00000000
|
|
|
|
// CHECK-NEXT: b1000000 00000000 03000000 00000000
|
|
|
|
// CHECK-NEXT: 02000000 00000000 c1000000 00000000
|
2017-07-18 04:42:52 +08:00
|
|
|
|
2016-02-11 09:07:19 +08:00
|
|
|
// CHECK: Contents of section .dtors:
|
2019-09-06 23:10:31 +08:00
|
|
|
// CHECK-NEXT: a2000000 00000000 11000000 00000000
|
|
|
|
// CHECK-NEXT: 14000000 00000000 15000000 00000000
|
|
|
|
// CHECK-NEXT: b2000000 00000000 13000000 00000000
|
|
|
|
// CHECK-NEXT: 12000000 00000000 c2000000 00000000
|