diff options
| author | Rui Ueyama <ruiu@google.com> | 2016-11-04 22:25:39 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2016-11-04 22:25:39 +0000 |
| commit | a9ee8d6eccfbe01c6c25829a26dd7c9c4286d222 (patch) | |
| tree | a9001b4cfd450219b03b2c66ea690734a2f18d9b | |
| parent | 4ce3e0c31ad6e40ee744fb879eeed2d3f3d0162a (diff) | |
| download | bcm5719-llvm-a9ee8d6eccfbe01c6c25829a26dd7c9c4286d222.tar.gz bcm5719-llvm-a9ee8d6eccfbe01c6c25829a26dd7c9c4286d222.zip | |
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.
llvm-svn: 286025
| -rw-r--r-- | lld/ELF/SyntheticSections.cpp | 6 | ||||
| -rw-r--r-- | lld/test/ELF/gc-sections-synthetic.s | 16 |
2 files changed, 21 insertions, 1 deletions
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp index 0df51b3d9f5..002656617ee 100644 --- a/lld/ELF/SyntheticSections.cpp +++ b/lld/ELF/SyntheticSections.cpp @@ -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 diff --git a/lld/test/ELF/gc-sections-synthetic.s b/lld/test/ELF/gc-sections-synthetic.s new file mode 100644 index 00000000000..5c36081a0f1 --- /dev/null +++ b/lld/test/ELF/gc-sections-synthetic.s @@ -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 |

