[lld] r362356 - [ELF] Don't create an output section named `/DISCARD/` if it is assigned to the special phdr `NONE`
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 2 22:34:26 PDT 2019
Author: maskray
Date: Sun Jun 2 22:34:25 2019
New Revision: 362356
URL: http://llvm.org/viewvc/llvm-project?rev=362356&view=rev
Log:
[ELF] Don't create an output section named `/DISCARD/` if it is assigned to the special phdr `NONE`
Fixes the remaining issue of PR41673 after D61186: with `/DISCARD/ { ... } :NONE`,
we may create an output section named `/DISCARD/`.
Note, if an input section is named `/DISCARD/`, ld.bfd discards it but
lld keeps it. It is probably not worth copying this behavior as it is unrealistic.
Reviewed By: ruiu
Differential Revision: https://reviews.llvm.org/D62768
Modified:
lld/trunk/ELF/LinkerScript.cpp
lld/trunk/test/ELF/linkerscript/discard-phdr.s
Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=362356&r1=362355&r2=362356&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Sun Jun 2 22:34:25 2019
@@ -824,6 +824,9 @@ void LinkerScript::assignOffsets(OutputS
}
static bool isDiscardable(OutputSection &Sec) {
+ if (Sec.Name == "/DISCARD/")
+ return true;
+
// We do not remove empty sections that are explicitly
// assigned to any segment.
if (!Sec.Phdrs.empty())
Modified: lld/trunk/test/ELF/linkerscript/discard-phdr.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/linkerscript/discard-phdr.s?rev=362356&r1=362355&r2=362356&view=diff
==============================================================================
--- lld/trunk/test/ELF/linkerscript/discard-phdr.s (original)
+++ lld/trunk/test/ELF/linkerscript/discard-phdr.s Sun Jun 2 22:34:25 2019
@@ -10,7 +10,7 @@
# RUN: /DISCARD/ : { *(.discard) } :NONE \
# RUN: }" > %t.script
# RUN: ld.lld -o %t --script %t.script %t.o
-# RUN: llvm-readelf -S -l %t | FileCheck %s
+# RUN: llvm-readelf -S -l %t | FileCheck --implicit-check-not=/DISCARD/ %s
## Check that /DISCARD/ does not interfere with the assignment of segments to
## sections.
More information about the llvm-commits
mailing list