[lld] r314867 - Remove BssSection::reserveSpace().
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 3 17:21:17 PDT 2017
Author: ruiu
Date: Tue Oct 3 17:21:17 2017
New Revision: 314867
URL: http://llvm.org/viewvc/llvm-project?rev=314867&view=rev
Log:
Remove BssSection::reserveSpace().
We no longer call reserveSpace more than once, so it can be merged with
its constructor.
Modified:
lld/trunk/ELF/Relocations.cpp
lld/trunk/ELF/SyntheticSections.cpp
lld/trunk/ELF/SyntheticSections.h
lld/trunk/ELF/Writer.cpp
Modified: lld/trunk/ELF/Relocations.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Relocations.cpp?rev=314867&r1=314866&r2=314867&view=diff
==============================================================================
--- lld/trunk/ELF/Relocations.cpp (original)
+++ lld/trunk/ELF/Relocations.cpp Tue Oct 3 17:21:17 2017
@@ -525,8 +525,8 @@ template <class ELFT> static void addCop
// See if this symbol is in a read-only segment. If so, preserve the symbol's
// memory protection by reserving space in the .bss.rel.ro section.
bool IsReadOnly = isReadOnly<ELFT>(SS);
- BssSection *Sec = make<BssSection>(IsReadOnly ? ".bss.rel.ro" : ".bss");
- Sec->reserveSpace(SymSize, SS->getAlignment<ELFT>());
+ BssSection *Sec = make<BssSection>(IsReadOnly ? ".bss.rel.ro" : ".bss",
+ SymSize, SS->getAlignment<ELFT>());
if (IsReadOnly)
InX::BssRelRo->getParent()->addSection(Sec);
else
Modified: lld/trunk/ELF/SyntheticSections.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.cpp?rev=314867&r1=314866&r2=314867&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.cpp (original)
+++ lld/trunk/ELF/SyntheticSections.cpp Tue Oct 3 17:21:17 2017
@@ -67,10 +67,9 @@ template <class ELFT> void elf::createCo
continue;
// Create a synthetic section for the common data.
- auto *Section = make<BssSection>("COMMON");
+ auto *Section = make<BssSection>("COMMON", Sym->Size, Sym->Alignment);
Section->File = Sym->getFile();
Section->Live = !Config->GcSections;
- Section->reserveSpace(Sym->Size, Sym->Alignment);
InputSections.push_back(Section);
// Replace all DefinedCommon symbols with DefinedRegular symbols so that we
@@ -361,15 +360,11 @@ void BuildIdSection::computeHash(
HashFn(HashBuf, Hashes);
}
-BssSection::BssSection(StringRef Name)
- : SyntheticSection(SHF_ALLOC | SHF_WRITE, SHT_NOBITS, 0, Name) {}
-
-size_t BssSection::reserveSpace(uint64_t Size, uint32_t Alignment) {
+BssSection::BssSection(StringRef Name, uint64_t Size, uint32_t Alignment)
+ : SyntheticSection(SHF_ALLOC | SHF_WRITE, SHT_NOBITS, Alignment, Name) {
if (OutputSection *Sec = getParent())
Sec->updateAlignment(Alignment);
- this->Size = alignTo(this->Size, Alignment) + Size;
- this->Alignment = std::max(this->Alignment, Alignment);
- return this->Size - Size;
+ this->Size = Size;
}
void BuildIdSection::writeBuildId(ArrayRef<uint8_t> Buf) {
Modified: lld/trunk/ELF/SyntheticSections.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SyntheticSections.h?rev=314867&r1=314866&r2=314867&view=diff
==============================================================================
--- lld/trunk/ELF/SyntheticSections.h (original)
+++ lld/trunk/ELF/SyntheticSections.h Tue Oct 3 17:21:17 2017
@@ -157,14 +157,13 @@ private:
// respectively.
class BssSection final : public SyntheticSection {
public:
- BssSection(StringRef Name);
+ BssSection(StringRef Name, uint64_t Size, uint32_t Alignment);
void writeTo(uint8_t *) override {}
bool empty() const override { return getSize() == 0; }
- size_t reserveSpace(uint64_t Size, uint32_t Alignment);
size_t getSize() const override { return Size; }
private:
- uint64_t Size = 0;
+ uint64_t Size;
};
class MipsGotSection final : public SyntheticSection {
Modified: lld/trunk/ELF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.cpp?rev=314867&r1=314866&r2=314867&view=diff
==============================================================================
--- lld/trunk/ELF/Writer.cpp (original)
+++ lld/trunk/ELF/Writer.cpp Tue Oct 3 17:21:17 2017
@@ -290,9 +290,9 @@ template <class ELFT> void Writer<ELFT>:
Add(InX::BuildId);
}
- InX::Bss = make<BssSection>(".bss");
+ InX::Bss = make<BssSection>(".bss", 0, 1);
Add(InX::Bss);
- InX::BssRelRo = make<BssSection>(".bss.rel.ro");
+ InX::BssRelRo = make<BssSection>(".bss.rel.ro", 0, 1);
Add(InX::BssRelRo);
// Add MIPS-specific sections.
More information about the llvm-commits
mailing list