From 17d6983a4e9b5488b1650e4ec68e679081bf98c1 Mon Sep 17 00:00:00 2001 From: Rui Ueyama Date: Thu, 10 Mar 2016 18:58:53 +0000 Subject: [PATCH] Rename MaxAlignment -> Alignment. We can argue about a maximum alignment of a group of symbols, but for each symbol, there is only one alignment. So it is a bit weird that each symbol has a "maximum alignment". llvm-svn: 263151 --- lld/ELF/Symbols.cpp | 9 +++------ lld/ELF/Symbols.h | 2 +- lld/ELF/Writer.cpp | 6 +++--- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/lld/ELF/Symbols.cpp b/lld/ELF/Symbols.cpp index 7203d54..f711520 100644 --- a/lld/ELF/Symbols.cpp +++ b/lld/ELF/Symbols.cpp @@ -107,8 +107,7 @@ static uint8_t getMinVisibility(uint8_t VA, uint8_t VB) { } static int compareCommons(DefinedCommon *A, DefinedCommon *B) { - A->MaxAlignment = B->MaxAlignment = - std::max(A->MaxAlignment, B->MaxAlignment); + A->Alignment = B->Alignment = std::max(A->Alignment, B->Alignment); if (A->Size < B->Size) return -1; return 1; @@ -191,10 +190,8 @@ DefinedSynthetic::DefinedSynthetic(StringRef N, uintX_t Value, DefinedCommon::DefinedCommon(StringRef N, uint64_t Size, uint64_t Alignment, bool IsWeak, uint8_t Visibility) : Defined(SymbolBody::DefinedCommonKind, N, IsWeak, Visibility, - 0 /* Type */) { - MaxAlignment = Alignment; - this->Size = Size; -} + 0 /* Type */), + Alignment(Alignment), Size(Size) {} std::unique_ptr Lazy::getMember() { MemoryBufferRef MBRef = File->getMember(&Sym); diff --git a/lld/ELF/Symbols.h b/lld/ELF/Symbols.h index 5ae0ab9..33986a8 100644 --- a/lld/ELF/Symbols.h +++ b/lld/ELF/Symbols.h @@ -205,7 +205,7 @@ public: uint64_t OffsetInBss; // The maximum alignment we have seen for this symbol. - uint64_t MaxAlignment; + uint64_t Alignment; uint64_t Size; }; diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp index ad01392..94a7a74 100644 --- a/lld/ELF/Writer.cpp +++ b/lld/ELF/Writer.cpp @@ -716,13 +716,13 @@ void Writer::addCommonSymbols(std::vector &Syms) { // Sort the common symbols by alignment as an heuristic to pack them better. std::stable_sort(Syms.begin(), Syms.end(), [](const DefinedCommon *A, const DefinedCommon *B) { - return A->MaxAlignment > B->MaxAlignment; + return A->Alignment > B->Alignment; }); uintX_t Off = getBss()->getSize(); for (DefinedCommon *C : Syms) { - Off = alignTo(Off, C->MaxAlignment); - Out::Bss->updateAlign(C->MaxAlignment); + Off = alignTo(Off, C->Alignment); + Out::Bss->updateAlign(C->Alignment); C->OffsetInBss = Off; Off += C->Size; } -- 2.7.4