2015-09-26 02:56:53 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
|
2015-10-03 03:37:55 +08:00
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld %t2 -o %t2.so -shared
|
|
|
|
// RUN: ld.lld %t %t2.so -o %t2
|
2015-10-07 10:51:44 +08:00
|
|
|
// RUN: llvm-readobj -r -symbols -sections -dynamic-table %t2 | FileCheck %s
|
2015-09-26 02:56:53 +08:00
|
|
|
// RUN: llvm-objdump -d %t2 | FileCheck --check-prefix=DISASM %s
|
|
|
|
// REQUIRES: x86
|
|
|
|
|
|
|
|
.globl _start
|
|
|
|
_start:
|
2015-10-06 09:16:17 +08:00
|
|
|
call __preinit_array_start
|
|
|
|
call __preinit_array_end
|
2015-09-26 02:56:53 +08:00
|
|
|
call __init_array_start
|
|
|
|
call __init_array_end
|
2015-10-06 09:16:17 +08:00
|
|
|
call __fini_array_start
|
|
|
|
call __fini_array_end
|
2015-09-26 02:56:53 +08:00
|
|
|
|
|
|
|
|
|
|
|
.section .init_array,"aw",@init_array
|
|
|
|
.quad 0
|
|
|
|
|
2015-10-03 03:37:55 +08:00
|
|
|
.section .preinit_array,"aw",@preinit_array
|
|
|
|
.quad 0
|
|
|
|
.byte 0
|
|
|
|
|
|
|
|
.section .fini_array,"aw",@fini_array
|
|
|
|
.quad 0
|
|
|
|
.short 0
|
2015-09-26 02:56:53 +08:00
|
|
|
|
|
|
|
// CHECK: Name: .init_array
|
|
|
|
// CHECK-NEXT: Type: SHT_INIT_ARRAY
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: SHF_ALLOC
|
|
|
|
// CHECK-NEXT: SHF_WRITE
|
|
|
|
// CHECK-NEXT: ]
|
2015-10-03 03:37:55 +08:00
|
|
|
// CHECK-NEXT: Address: [[INIT_ADDR:.*]]
|
2015-09-26 02:56:53 +08:00
|
|
|
// CHECK-NEXT: Offset:
|
2015-10-03 03:37:55 +08:00
|
|
|
// CHECK-NEXT: Size: [[INIT_SIZE:.*]]
|
|
|
|
|
|
|
|
|
|
|
|
// CHECK: Name: .preinit_array
|
|
|
|
// CHECK-NEXT: Type: SHT_PREINIT_ARRAY
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: SHF_ALLOC
|
|
|
|
// CHECK-NEXT: SHF_WRITE
|
|
|
|
// CHECK-NEXT: ]
|
|
|
|
// CHECK-NEXT: Address: [[PREINIT_ADDR:.*]]
|
|
|
|
// CHECK-NEXT: Offset:
|
|
|
|
// CHECK-NEXT: Size: [[PREINIT_SIZE:.*]]
|
|
|
|
|
|
|
|
|
|
|
|
// CHECK: Name: .fini_array
|
|
|
|
// CHECK-NEXT: Type: SHT_FINI_ARRAY
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: SHF_ALLOC
|
|
|
|
// CHECK-NEXT: SHF_WRITE
|
|
|
|
// CHECK-NEXT: ]
|
|
|
|
// CHECK-NEXT: Address: [[FINI_ADDR:.*]]
|
|
|
|
// CHECK-NEXT: Offset:
|
|
|
|
// CHECK-NEXT: Size: [[FINI_SIZE:.*]]
|
2015-09-26 02:56:53 +08:00
|
|
|
|
2015-10-07 10:51:44 +08:00
|
|
|
// CHECK: Relocations [
|
|
|
|
// CHECK-NEXT: ]
|
|
|
|
|
2015-10-06 09:16:17 +08:00
|
|
|
// CHECK: Name: __fini_array_end
|
2015-10-11 07:25:39 +08:00
|
|
|
// CHECK-NEXT: Value: 0x1201B
|
2015-10-06 09:16:17 +08:00
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Local
|
|
|
|
// CHECK-NEXT: Type: None
|
2015-10-19 23:21:42 +08:00
|
|
|
// CHECK-NEXT: Other: 0
|
2015-10-06 09:16:17 +08:00
|
|
|
// CHECK-NEXT: Section: .fini_array
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Symbol {
|
|
|
|
// CHECK-NEXT: Name: __fini_array_start
|
|
|
|
// CHECK-NEXT: Value: [[FINI_ADDR]]
|
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Local
|
|
|
|
// CHECK-NEXT: Type: None
|
2015-10-19 23:21:42 +08:00
|
|
|
// CHECK-NEXT: Other: 0
|
2015-10-06 09:16:17 +08:00
|
|
|
// CHECK-NEXT: Section: .fini_array
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Symbol {
|
|
|
|
// CHECK-NEXT: Name: __init_array_end
|
2015-10-11 07:25:39 +08:00
|
|
|
// CHECK-NEXT: Value: 0x12008
|
2015-09-26 02:56:53 +08:00
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Local
|
|
|
|
// CHECK-NEXT: Type: None
|
2015-10-19 23:21:42 +08:00
|
|
|
// CHECK-NEXT: Other: 0
|
2015-09-26 02:56:53 +08:00
|
|
|
// CHECK-NEXT: Section: .init_array
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Symbol {
|
|
|
|
// CHECK-NEXT: Name: __init_array_start
|
2015-10-03 03:37:55 +08:00
|
|
|
// CHECK-NEXT: Value: [[INIT_ADDR]]
|
2015-09-26 02:56:53 +08:00
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Local
|
|
|
|
// CHECK-NEXT: Type: None
|
2015-10-19 23:21:42 +08:00
|
|
|
// CHECK-NEXT: Other: 0
|
2015-09-26 02:56:53 +08:00
|
|
|
// CHECK-NEXT: Section: .init_array
|
|
|
|
// CHECK-NEXT: }
|
2015-10-06 09:16:17 +08:00
|
|
|
// CHECK-NEXT: Symbol {
|
|
|
|
// CHECK-NEXT: Name: __preinit_array_end
|
2015-10-11 07:25:39 +08:00
|
|
|
// CHECK-NEXT: Value: 0x12011
|
2015-10-06 09:16:17 +08:00
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Local
|
|
|
|
// CHECK-NEXT: Type: None
|
2015-10-19 23:21:42 +08:00
|
|
|
// CHECK-NEXT: Other: 0
|
2015-10-06 09:16:17 +08:00
|
|
|
// CHECK-NEXT: Section: .preinit_array
|
|
|
|
// CHECK-NEXT: }
|
|
|
|
// CHECK-NEXT: Symbol {
|
|
|
|
// CHECK-NEXT: Name: __preinit_array_start
|
|
|
|
// CHECK-NEXT: Value: [[PREINIT_ADDR]]
|
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Local
|
|
|
|
// CHECK-NEXT: Type: None
|
2015-10-19 23:21:42 +08:00
|
|
|
// CHECK-NEXT: Other: 0
|
2015-10-06 09:16:17 +08:00
|
|
|
// CHECK-NEXT: Section: .preinit_array
|
|
|
|
// CHECK-NEXT: }
|
2015-10-03 03:37:55 +08:00
|
|
|
|
|
|
|
// CHECK: DynamicSection
|
|
|
|
// CHECK: PREINIT_ARRAY [[PREINIT_ADDR]]
|
|
|
|
// CHECK: PREINIT_ARRAYSZ [[PREINIT_SIZE]] (bytes)
|
|
|
|
// CHECK: INIT_ARRAY [[INIT_ADDR]]
|
|
|
|
// CHECK: INIT_ARRAYSZ [[INIT_SIZE]] (bytes)
|
|
|
|
// CHECK: FINI_ARRAY [[FINI_ADDR]]
|
|
|
|
// CHECK: FINI_ARRAYSZ [[FINI_SIZE]] (bytes)
|
|
|
|
|
|
|
|
|
2015-10-11 07:25:39 +08:00
|
|
|
// 0x12008 - (0x11000 + 5) = 4099
|
|
|
|
// 0x12011 - (0x11005 + 5) = 4103
|
|
|
|
// 0x12000 - (0x1100a + 5) = 4081
|
|
|
|
// 0x12008 - (0x1100f + 5) = 4084
|
|
|
|
// 0x12011 - (0x11014 + 5) = 4088
|
|
|
|
// 0x1201B - (0x11019 + 5) = 4093
|
2015-09-26 02:56:53 +08:00
|
|
|
// DISASM: _start:
|
2015-10-11 07:25:39 +08:00
|
|
|
// DISASM-NEXT: 11000: e8 {{.*}} callq 4099
|
|
|
|
// DISASM-NEXT: 11005: e8 {{.*}} callq 4103
|
|
|
|
// DISASM-NEXT: 1100a: e8 {{.*}} callq 4081
|
|
|
|
// DISASM-NEXT: 1100f: e8 {{.*}} callq 4084
|
|
|
|
// DISASM-NEXT: 11014: e8 {{.*}} callq 4088
|
|
|
|
// DISASM-NEXT: 11019: e8 {{.*}} callq 4093
|