2015-10-05 18:29:46 +08:00
|
|
|
// REQUIRES: x86
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
|
|
|
|
|
|
|
|
// Should use "_init" and "_fini" by default when fills dynamic table
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -shared %t -o %t2
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj --dynamic-table %t2 | FileCheck --check-prefix=BYDEF %s
|
2015-10-05 18:29:46 +08:00
|
|
|
// BYDEF: INIT 0x11010
|
|
|
|
// BYDEF: FINI 0x11020
|
|
|
|
|
|
|
|
// -init and -fini override symbols to use
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -shared %t -o %t2 -init _foo -fini _bar
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj --dynamic-table %t2 | FileCheck --check-prefix=OVR %s
|
2015-10-05 18:29:46 +08:00
|
|
|
// OVR: INIT 0x11030
|
|
|
|
// OVR: FINI 0x11040
|
|
|
|
|
|
|
|
// Check aliases as well
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -shared %t -o %t2 -init=_foo -fini=_bar
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj --dynamic-table %t2 | FileCheck --check-prefix=OVR %s
|
2015-10-05 18:29:46 +08:00
|
|
|
|
2017-01-14 03:18:11 +08:00
|
|
|
// Don't add an entry for undef. The freebsd dynamic linker doesn't
|
|
|
|
// check if the value is null. If it is, it will just call the
|
|
|
|
// load address.
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -shared %t -o %t2 -init=_undef -fini=_undef
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj --dynamic-table %t2 | FileCheck --check-prefix=UNDEF %s
|
2017-01-14 03:18:11 +08:00
|
|
|
// UNDEF-NOT: INIT
|
|
|
|
// UNDEF-NOT: FINI
|
|
|
|
|
|
|
|
// Don't add an entry for shared. For the same reason as undef.
|
|
|
|
// RUN: ld.lld -shared %t -o %t.so
|
|
|
|
// RUN: echo > %t.s
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t.s -o %t2.o
|
|
|
|
// RUN: ld.lld -shared %t2.o %t.so -o %t2
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj --dynamic-table %t2 | FileCheck --check-prefix=SHARED %s
|
2017-01-14 03:18:11 +08:00
|
|
|
// SHARED-NOT: INIT
|
|
|
|
// SHARED-NOT: FINI
|
2015-10-05 18:29:46 +08:00
|
|
|
|
|
|
|
// Should not add new entries to the symbol table
|
|
|
|
// and should not require given symbols to be resolved
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -shared %t -o %t2 -init=_unknown -fini=_unknown
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj --symbols --dynamic-table %t2 | FileCheck --check-prefix=NOENTRY %s
|
2015-10-05 18:29:46 +08:00
|
|
|
// NOENTRY: DynamicSection [
|
|
|
|
// NOENTRY-NOT: INIT
|
|
|
|
// NOENTRY-NOT: FINI
|
|
|
|
// NOENTRY: ]
|
2020-03-04 11:49:14 +08:00
|
|
|
// NOENTRY: Symbols [
|
|
|
|
// NOENTRY-NOT: Name: _unknown
|
|
|
|
// NOENTRY: ]
|
2015-10-05 18:29:46 +08:00
|
|
|
|
2020-07-14 16:54:35 +08:00
|
|
|
// Should not add entries for "_init" and "_fini" to the symbol table
|
|
|
|
// if the symbols are defined in non-fetched achive members.
|
|
|
|
// RUN: rm -f %t.a
|
|
|
|
// RUN: llvm-ar rcs %t.a %t
|
|
|
|
// RUN: ld.lld -shared -m elf_x86_64 -e _unknown %t.a -o %t.so
|
|
|
|
// RUN: llvm-nm %t.so | \
|
|
|
|
// RUN: FileCheck %s --implicit-check-not=_init --implicit-check-not=_fini
|
|
|
|
|
2016-04-27 10:58:27 +08:00
|
|
|
.global _start,_init,_fini,_foo,_bar,_undef
|
2015-10-05 18:29:46 +08:00
|
|
|
_start:
|
|
|
|
_init = 0x11010
|
|
|
|
_fini = 0x11020
|
|
|
|
_foo = 0x11030
|
|
|
|
_bar = 0x11040
|