summaryrefslogtreecommitdiff
path: root/lld/ELF/LinkerScript.cpp
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2019-04-18 09:22:05 +0000
committerFangrui Song <maskray@google.com>2019-04-18 09:22:05 +0000
commit3deff86657c8a479c4c5d2fdd12c49a75293a8e1 (patch)
tree3cecd5babebad27b8ed674499c0ad06e5e2d943b /lld/ELF/LinkerScript.cpp
parent66a9d0f8c6c90d4235d23d190be5494f06763c57 (diff)
[ELF] Respect NonAlloc when copying flags from the previous sections
Summary: If the output section contains only symbol assignments, we copy flags from the previous sections. Don't set SHF_ALLOC if NonAlloc is true. We also have to change the type from SHT_NOBITS to SHT_PROGBITS. In ld.bfd, bfd_elf_get_default_section_type maps non-alloctable sections to SHT_PROGBITS. Non-alloctable SHT_NOBITS sections do not make sense. Fixes PR38626 Differential Revision: https://reviews.llvm.org/D59986 llvm-svn: 358650
Diffstat (limited to 'lld/ELF/LinkerScript.cpp')
-rw-r--r--lld/ELF/LinkerScript.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index c4a63f5c852a..c06c3bd9acb4 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -887,7 +887,8 @@ void LinkerScript::adjustSectionsBeforeSorting() {
// in case it is empty.
bool IsEmpty = getInputSections(Sec).empty();
if (IsEmpty)
- Sec->Flags = Flags & (SHF_ALLOC | SHF_WRITE | SHF_EXECINSTR);
+ Sec->Flags =
+ Flags & ((Sec->NonAlloc ? 0 : SHF_ALLOC) | SHF_WRITE | SHF_EXECINSTR);
if (IsEmpty && isDiscardable(*Sec)) {
Sec->Live = false;