1// REQUIRES: x86 2// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t 3// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2 4// RUN: ld.lld %t2 -o %t2.so -shared -soname=so 5// RUN: ld.lld %t %t2.so -o %t2 6// RUN: llvm-readelf -S -d -r -s %t2 | FileCheck %s 7// RUN: llvm-objdump -d --syms %t2 | FileCheck --check-prefix=DISASM %s 8 9.globl _start 10_start: 11 call *__preinit_array_start 12 call *__preinit_array_end 13 call *__init_array_start 14 call *__init_array_end 15 call *__fini_array_start 16 call *__fini_array_end 17 18 19.section .init_array,"aw",@init_array 20 .quad 0 21 22.section .preinit_array,"aw",@preinit_array 23 .quad 0 24 .byte 0 25 26.section .fini_array,"aw",@fini_array 27 .quad 0 28 .short 0 29 30// CHECK-LABEL: Section Headers: 31// CHECK: Name Type Address Off Size ES Flg 32// CHECK: .init_array INIT_ARRAY [[# %x, INIT_ADDR:]] [[# %x,]] [[# %x, INIT_SIZE:]] 00 WA 33// CHECK-NEXT: .preinit_array PREINIT_ARRAY [[# %x, PREINIT_ADDR:]] [[# %x,]] [[# %x, PREINIT_SIZE:]] 00 WA 34// CHECK-NEXT: .fini_array FINI_ARRAY [[# %x, FINI_ADDR:]] [[# %x,]] [[# %x, FINI_SIZE:]] 00 WA 35 36// CHECK-LABEL: Dynamic section 37// CHECK: (PREINIT_ARRAY) 0x[[# PREINIT_ADDR]] 38// CHECK: (PREINIT_ARRAYSZ) [[# %u, PREINIT_SIZE]] (bytes) 39// CHECK: (INIT_ARRAY) 0x[[# INIT_ADDR]] 40// CHECK: (INIT_ARRAYSZ) [[# %u, INIT_SIZE]] (bytes) 41// CHECK: (FINI_ARRAY) 0x[[# FINI_ADDR]] 42// CHECK: (FINI_ARRAYSZ) [[# %u, FINI_SIZE]] (bytes) 43 44// CHECK-LABEL: There are no relocations in this file. 45 46// CHECK-LABEL: Symbol table '.symtab' 47// CHECK: Value Size Type Bind Vis Ndx Name 48// CHECK: [[# FINI_ADDR + FINI_SIZE]] 0 NOTYPE LOCAL HIDDEN [[#]] __fini_array_end 49// CHECK-NEXT: [[# FINI_ADDR]] 0 NOTYPE LOCAL HIDDEN [[#]] __fini_array_start 50// CHECK-NEXT: [[# INIT_ADDR + INIT_SIZE]] 0 NOTYPE LOCAL HIDDEN [[#]] __init_array_end 51// CHECK-NEXT: [[# INIT_ADDR]] 0 NOTYPE LOCAL HIDDEN [[#]] __init_array_start 52// CHECK-NEXT: [[# PREINIT_ADDR + PREINIT_SIZE]] 0 NOTYPE LOCAL HIDDEN [[#]] __preinit_array_end 53// CHECK-NEXT: [[# PREINIT_ADDR]] 0 NOTYPE LOCAL HIDDEN [[#]] __preinit_array_start 54 55// DISASM: SYMBOL TABLE: 56// DISASM-DAG: {{0*}}[[# %x, PREINIT_ARRAY_START:]] l .preinit_array {{0+}} .hidden __preinit_array_start 57// DISASM-DAG: {{0*}}[[# %x, PREINIT_ARRAY_END:]] l .preinit_array {{0+}} .hidden __preinit_array_end 58// DISASM-DAG: {{0*}}[[# %x, INIT_ARRAY_START:]] l .init_array {{0+}} .hidden __init_array_start 59// DISASM-DAG: {{0*}}[[# %x, INIT_ARRAY_END:]] l .init_array {{0+}} .hidden __init_array_end 60// DISASM-DAG: {{0*}}[[# %x, FINI_ARRAY_START:]] l .fini_array {{0+}} .hidden __fini_array_start 61// DISASM-DAG: {{0*}}[[# %x, FINI_ARRAY_END:]] l .fini_array {{0+}} .hidden __fini_array_end 62 63// DISASM: <_start>: 64// DISASM-NEXT: callq *[[# %u, PREINIT_ARRAY_START]] 65// DISASM-NEXT: callq *[[# %u, PREINIT_ARRAY_END]] 66// DISASM-NEXT: callq *[[# %u, INIT_ARRAY_START]] 67// DISASM-NEXT: callq *[[# %u, INIT_ARRAY_END]] 68// DISASM-NEXT: callq *[[# %u, FINI_ARRAY_START]] 69// DISASM-NEXT: callq *[[# %u, FINI_ARRAY_END]] 70