[PATCH] D38136: [ELF] Simplify handling of removed sections
ben via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 21 08:31:12 PDT 2017
bd1976llvm created this revision.
Herald added a subscriber: emaste.
Simplify handling of removed sections by testing the Live bit to see if the section was removed.
The code is simpler, and the lack of this test caused confusion (see: https://reviews.llvm.org/D37718).
https://reviews.llvm.org/D38136
Files:
ELF/LinkerScript.cpp
ELF/Symbols.cpp
ELF/Writer.cpp
Index: ELF/Writer.cpp
===================================================================
--- ELF/Writer.cpp
+++ ELF/Writer.cpp
@@ -270,8 +270,10 @@
Out::ElfHeader = make<OutputSection>("", 0, SHF_ALLOC);
Out::ElfHeader->Size = sizeof(Elf_Ehdr);
+ Out::ElfHeader->Live = true;
Out::ProgramHeaders = make<OutputSection>("", 0, SHF_ALLOC);
Out::ProgramHeaders->updateAlignment(Config->Wordsize);
+ Out::ProgramHeaders->Live = true;
if (needsInterpSection()) {
InX::Interp = createInterpSection();
Index: ELF/Symbols.cpp
===================================================================
--- ELF/Symbols.cpp
+++ ELF/Symbols.cpp
@@ -48,17 +48,13 @@
if (auto *ISB = dyn_cast_or_null<InputSectionBase>(IS))
IS = ISB->Repl;
- // According to the ELF spec reference to a local symbol from outside
- // the group are not allowed. Unfortunately .eh_frame breaks that rule
- // and must be treated specially. For now we just replace the symbol with
- // 0.
- if (IS == &InputSection::Discarded)
- return 0;
-
// This is an absolute symbol.
if (!IS)
return D.Value;
+ if (!IS->Live)
+ return 0;
+
uint64_t Offset = D.Value;
// An object in an SHF_MERGE section might be referenced via a
Index: ELF/LinkerScript.cpp
===================================================================
--- ELF/LinkerScript.cpp
+++ ELF/LinkerScript.cpp
@@ -358,6 +358,7 @@
// which will map to whatever the first actual section is.
Aether = make<OutputSection>("", 0, SHF_ALLOC);
Aether->SectionIndex = 1;
+ Aether->Live = true;
auto State = make_unique<AddressState>(Opt);
// CurAddressState captures the local AddressState and makes it accessible
// deliberately. This is needed as there are some cases where we cannot just
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38136.116193.patch
Type: text/x-patch
Size: 1813 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170921/3d900995/attachment.bin>
More information about the llvm-commits
mailing list