From 27be542cdf4c1c81a4e694ebcaec9253f8acad00 Mon Sep 17 00:00:00 2001 From: Eugene Leviant Date: Wed, 28 Sep 2016 08:42:02 +0000 Subject: [PATCH] [ELF] Ignore sections flagged with SHF_EXCLUDE Differential revision: https://reviews.llvm.org/D24966 llvm-svn: 282568 --- lld/ELF/InputFiles.cpp | 5 +++++ lld/test/ELF/exclude.s | 12 ++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 lld/test/ELF/exclude.s diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp index 7d6a36815cdd..d9d8df50a08b 100644 --- a/lld/ELF/InputFiles.cpp +++ b/lld/ELF/InputFiles.cpp @@ -226,6 +226,11 @@ void elf::ObjectFile::initializeSections( if (Sections[I] == &InputSection::Discarded) continue; + if (Sec.sh_flags & SHF_EXCLUDE) { + Sections[I] = &InputSection::Discarded; + continue; + } + switch (Sec.sh_type) { case SHT_GROUP: Sections[I] = &InputSection::Discarded; diff --git a/lld/test/ELF/exclude.s b/lld/test/ELF/exclude.s new file mode 100644 index 000000000000..addc3dc72ec7 --- /dev/null +++ b/lld/test/ELF/exclude.s @@ -0,0 +1,12 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t +# RUN: ld.lld -o %t1 %t +# RUN: llvm-objdump -section-headers %t1 | FileCheck %s +# CHECK-NOT: .aaa + +.globl _start +_start: + jmp _start + +.section .aaa,"ae" + .quad 0