• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1// REQUIRES: x86
2// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
3
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
9
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
15
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
19
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
27
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
36
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: ]
48
49// Should not add entries for "_init" and "_fini" to the symbol table
50// if the symbols are defined in non-fetched achive 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
56
57.global _start,_init,_fini,_foo,_bar,_undef
58_start:
59_init = 0x11010
60_fini = 0x11020
61_foo  = 0x11030
62_bar  = 0x11040
63