forked from OSchip/llvm-project
[ELF] Don't reclaim .ctors/.dtors sections.
In FreeBSD, rtld expects .ctors containing -1 (0xffffffff), and a .ctors section containing the correct bits is provided to the linker as input (/usr/lib/crtbegin.o). Contents of section .ctors: 0000 ffffffff ffffffff ........ This section is not stripped even if not referenced or empty, also in gold or ld.bfd. It would be nice to strip it when not needed but since existing object files rely on that we can't do better to keep it around. Differential Revision: http://reviews.llvm.org/D15767 llvm-svn: 256373
This commit is contained in:
parent
7924fb8142
commit
bcbfedc927
|
@ -70,7 +70,8 @@ template <class ELFT> static bool isReserved(InputSectionBase<ELFT> *Sec) {
|
|||
return true;
|
||||
default:
|
||||
StringRef S = Sec->getSectionName();
|
||||
return S.startswith(".init") || S.startswith(".fini") ||
|
||||
return S.startswith(".ctors") || S.startswith(".dtors") ||
|
||||
S.startswith(".init") || S.startswith(".fini") ||
|
||||
S.startswith(".jcr");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
|
||||
# NOGC: Name: .eh_frame
|
||||
# NOGC: Name: .text
|
||||
# NOGC: Name: .ctors
|
||||
# NOGC: Name: .dtors
|
||||
# NOGC: Name: .init
|
||||
# NOGC: Name: .fini
|
||||
# NOGC: Name: a
|
||||
|
@ -23,6 +25,8 @@
|
|||
|
||||
# GC1: Name: .eh_frame
|
||||
# GC1: Name: .text
|
||||
# GC1: Name: .ctors
|
||||
# GC1: Name: .dtors
|
||||
# GC1: Name: .init
|
||||
# GC1: Name: .fini
|
||||
# GC1: Name: a
|
||||
|
@ -36,6 +40,8 @@
|
|||
|
||||
# GC2: Name: .eh_frame
|
||||
# GC2: Name: .text
|
||||
# GC2: Name: .ctors
|
||||
# GC2: Name: .dtors
|
||||
# GC2: Name: .init
|
||||
# GC2: Name: .fini
|
||||
# GC2: Name: a
|
||||
|
@ -77,6 +83,12 @@ x:
|
|||
y:
|
||||
call x
|
||||
|
||||
.section .ctors,"aw",@progbits
|
||||
.quad 0
|
||||
|
||||
.section .dtors,"aw",@progbits
|
||||
.quad 0
|
||||
|
||||
.section .init,"aw",@init_array
|
||||
.quad 0
|
||||
|
||||
|
|
Loading…
Reference in New Issue