[lld] r286025 - Don't gc .interp section.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 4 15:25:39 PDT 2016
Author: ruiu
Date: Fri Nov 4 17:25:39 2016
New Revision: 286025
URL: http://llvm.org/viewvc/llvm-project?rev=286025&view=rev
Log:
Don't gc .interp section.
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.
Added:
lld/trunk/test/ELF/gc-sections-synthetic.s
Modified:
lld/trunk/ELF/SyntheticSections.cpp
Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=286025&r1=286024&r2=286025&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Fri Nov 4 17:25:39 2016
@@ -46,12 +46,16 @@ static ArrayRef<uint8_t> createInterp()
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
Added: lld/trunk/test/ELF/gc-sections-synthetic.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/gc-sections-synthetic.s?rev=286025&view=auto
==============================================================================
--- lld/trunk/test/ELF/gc-sections-synthetic.s (added)
+++ lld/trunk/test/ELF/gc-sections-synthetic.s Fri Nov 4 17:25:39 2016
@@ -0,0 +1,16 @@
+# 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
More information about the llvm-commits
mailing list