[memprof] Remove an unused using directive (#117004)
[llvm-project.git] / lld / test / ELF / init-fini.s
blobdbfb48f4902691b5732cbe7f8a4a5dbda12b1205
1 // REQUIRES: x86
2 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
4 // Should use "_init" and "_fini" by default when fills dynamic table
5 // RUN: ld.lld -shared %t -o %t2
6 // RUN: llvm-readobj --dynamic-table %t2 | FileCheck --check-prefix=BYDEF %s
7 // BYDEF: INIT 0x11010
8 // BYDEF: FINI 0x11020
10 // -init and -fini override symbols to use
11 // RUN: ld.lld -shared %t -o %t2 -init _foo -fini _bar
12 // RUN: llvm-readobj --dynamic-table %t2 | FileCheck --check-prefix=OVR %s
13 // OVR: INIT 0x11030
14 // OVR: FINI 0x11040
16 // Check aliases as well
17 // RUN: ld.lld -shared %t -o %t2 -init=_foo -fini=_bar
18 // RUN: llvm-readobj --dynamic-table %t2 | FileCheck --check-prefix=OVR %s
20 // Don't add an entry for undef. The freebsd dynamic linker doesn't
21 // check if the value is null. If it is, it will just call the
22 // load address.
23 // RUN: ld.lld -shared %t -o %t2 -init=_undef -fini=_undef
24 // RUN: llvm-readobj --dynamic-table %t2 | FileCheck --check-prefix=UNDEF %s
25 // UNDEF-NOT: INIT
26 // UNDEF-NOT: FINI
28 // Don't add an entry for shared. For the same reason as undef.
29 // RUN: ld.lld -shared %t -o %t.so
30 // RUN: echo > %t.s
31 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t.s -o %t2.o
32 // RUN: ld.lld -shared %t2.o %t.so -o %t2
33 // RUN: llvm-readobj --dynamic-table %t2 | FileCheck --check-prefix=SHARED %s
34 // SHARED-NOT: INIT
35 // SHARED-NOT: FINI
37 // Should not add new entries to the symbol table
38 // and should not require given symbols to be resolved
39 // RUN: ld.lld -shared %t -o %t2 -init=_unknown -fini=_unknown
40 // RUN: llvm-readobj --symbols --dynamic-table %t2 | FileCheck --check-prefix=NOENTRY %s
41 // NOENTRY: DynamicSection [
42 // NOENTRY-NOT: INIT
43 // NOENTRY-NOT: FINI
44 // NOENTRY: ]
45 // NOENTRY: Symbols [
46 // NOENTRY-NOT: Name: _unknown
47 // NOENTRY: ]
49 // Should not add entries for "_init" and "_fini" to the symbol table
50 // if the symbols are defined in non-fetched archive members.
51 // RUN: rm -f %t.a
52 // RUN: llvm-ar rcs %t.a %t
53 // RUN: ld.lld -shared -m elf_x86_64 -e _unknown %t.a -o %t.so
54 // RUN: llvm-nm %t.so | \
55 // RUN: FileCheck %s --implicit-check-not=_init --implicit-check-not=_fini
57 .global _start,_init,_fini,_foo,_bar,_undef
58 _start:
59 _init = 0x11010
60 _fini = 0x11020
61 _foo = 0x11030
62 _bar = 0x11040