[PATCH] D62768: [ELF] Don't create an output section named `/DISCARD/` if it is assigned to the special phdr `NONE`
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 31 21:28:22 PDT 2019
MaskRay created this revision.
MaskRay added reviewers: andrewng, grimar, ruiu.
Herald added subscribers: llvm-commits, arichardson, emaste.
Herald added a reviewer: espindola.
Herald added a project: LLVM.
Fixes the remaining issue of PR41673 after D61186 <https://reviews.llvm.org/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.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D62768
Files:
ELF/LinkerScript.cpp
test/ELF/linkerscript/discard-phdr.s
Index: test/ELF/linkerscript/discard-phdr.s
===================================================================
--- test/ELF/linkerscript/discard-phdr.s
+++ test/ELF/linkerscript/discard-phdr.s
@@ -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.
Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ ELF/LinkerScript.cpp
@@ -824,6 +824,9 @@
}
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())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62768.202529.patch
Type: text/x-patch
Size: 929 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190601/4923f35c/attachment.bin>
More information about the llvm-commits
mailing list