This change fixes a bug that was introduced by r285851.
r285851 converted .interp section as an output section to an input
section. But I forgot to make it a "Live" section, so if -gc-section
is given, it was garbage collected.
llvm-svn: 286025
template <class ELFT>
InterpSection<ELFT>::InterpSection()
: InputSection<ELFT>(SHF_ALLOC, SHT_PROGBITS, 1, createInterp(),
- ".interp") {}
+ ".interp") {
+ this->Live = true;
+}
template <class ELFT>
BuildIdSection<ELFT>::BuildIdSection(size_t HashSize)
: InputSection<ELFT>(SHF_ALLOC, SHT_NOTE, 1, ArrayRef<uint8_t>(),
".note.gnu.build-id") {
+ this->Live = true;
+
Buf.resize(16 + HashSize);
const endianness E = ELFT::TargetEndianness;
write32<E>(Buf.data(), 4); // Name size
--- /dev/null
+# REQUIRES: x86
+
+# Linker-synthesized sections shouldn't be gc'ed.
+
+# RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %p/Inputs/shared.s -o %t.o
+# RUN: ld.lld %t2 -shared -o %t.so
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t2
+# RUN: ld.lld %t2 %t.so -build-id -dynamic-linker /foo/bar -o %t.out
+# RUN: llvm-readobj -sections %t.out | FileCheck %s
+
+# CHECK: Name: .interp
+# CHECK: Name: .note.gnu.build-id
+
+.globl _start
+_start:
+ ret