[lld] r257220 - COFF: Rename RoundUpToAlignment -> align.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 8 14:24:26 PST 2016
Author: ruiu
Date: Fri Jan 8 16:24:26 2016
New Revision: 257220
URL: http://llvm.org/viewvc/llvm-project?rev=257220&view=rev
Log:
COFF: Rename RoundUpToAlignment -> align.
Modified:
lld/trunk/COFF/Chunks.cpp
lld/trunk/COFF/Chunks.h
lld/trunk/COFF/DLL.cpp
lld/trunk/COFF/InputFiles.cpp
lld/trunk/COFF/Writer.cpp
Modified: lld/trunk/COFF/Chunks.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.cpp?rev=257220&r1=257219&r2=257220&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.cpp (original)
+++ lld/trunk/COFF/Chunks.cpp Fri Jan 8 16:24:26 2016
@@ -310,7 +310,7 @@ void SEHTableChunk::writeTo(uint8_t *Buf
BaserelChunk::BaserelChunk(uint32_t Page, Baserel *Begin, Baserel *End) {
// Block header consists of 4 byte page RVA and 4 byte block size.
// Each entry is 2 byte. Last entry may be padding.
- Data.resize(RoundUpToAlignment((End - Begin) * 2 + 8, 4));
+ Data.resize(align((End - Begin) * 2 + 8, 4));
uint8_t *P = Data.data();
write32le(P, Page);
write32le(P + 4, Data.size());
Modified: lld/trunk/COFF/Chunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Chunks.h?rev=257220&r1=257219&r2=257220&view=diff
==============================================================================
--- lld/trunk/COFF/Chunks.h (original)
+++ lld/trunk/COFF/Chunks.h Fri Jan 8 16:24:26 2016
@@ -326,6 +326,10 @@ public:
uint8_t Type;
};
+inline uint64_t align(uint64_t Value, uint64_t Align) {
+ return llvm::RoundUpToAlignment(Value, Align);
+}
+
} // namespace coff
} // namespace lld
Modified: lld/trunk/COFF/DLL.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/DLL.cpp?rev=257220&r1=257219&r2=257220&view=diff
==============================================================================
--- lld/trunk/COFF/DLL.cpp (original)
+++ lld/trunk/COFF/DLL.cpp Fri Jan 8 16:24:26 2016
@@ -45,7 +45,7 @@ public:
size_t getSize() const override {
// Starts with 2 byte Hint field, followed by a null-terminated string,
// ends with 0 or 1 byte padding.
- return RoundUpToAlignment(Name.size() + 3, 2);
+ return align(Name.size() + 3, 2);
}
void writeTo(uint8_t *Buf) const override {
Modified: lld/trunk/COFF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=257220&r1=257219&r2=257220&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.cpp (original)
+++ lld/trunk/COFF/InputFiles.cpp Fri Jan 8 16:24:26 2016
@@ -23,7 +23,6 @@
using namespace llvm::COFF;
using namespace llvm::object;
using namespace llvm::support::endian;
-using llvm::RoundUpToAlignment;
using llvm::Triple;
using llvm::support::ulittle32_t;
using llvm::sys::fs::file_magic;
Modified: lld/trunk/COFF/Writer.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Writer.cpp?rev=257220&r1=257219&r2=257220&view=diff
==============================================================================
--- lld/trunk/COFF/Writer.cpp (original)
+++ lld/trunk/COFF/Writer.cpp Fri Jan 8 16:24:26 2016
@@ -163,13 +163,13 @@ void OutputSection::addChunk(Chunk *C) {
Chunks.push_back(C);
C->setOutputSection(this);
uint64_t Off = Header.VirtualSize;
- Off = RoundUpToAlignment(Off, C->getAlign());
+ Off = align(Off, C->getAlign());
C->setRVA(Off);
C->setOutputSectionOff(Off);
Off += C->getSize();
Header.VirtualSize = Off;
if (C->hasData())
- Header.SizeOfRawData = RoundUpToAlignment(Off, SectorSize);
+ Header.SizeOfRawData = align(Off, SectorSize);
}
void OutputSection::addPermissions(uint32_t C) {
@@ -448,15 +448,14 @@ void Writer::createSymbolAndStringTable(
OutputSection *LastSection = OutputSections.back();
// We position the symbol table to be adjacent to the end of the last section.
uint64_t FileOff =
- LastSection->getFileOff() +
- RoundUpToAlignment(LastSection->getRawSize(), SectorSize);
+ LastSection->getFileOff() + align(LastSection->getRawSize(), SectorSize);
if (!OutputSymtab.empty()) {
PointerToSymbolTable = FileOff;
FileOff += OutputSymtab.size() * sizeof(coff_symbol16);
}
if (!Strtab.empty())
FileOff += Strtab.size() + 4;
- FileSize = RoundUpToAlignment(FileOff, SectorSize);
+ FileSize = align(FileOff, SectorSize);
}
// Visits all sections to assign incremental, non-overlapping RVAs and
@@ -467,7 +466,7 @@ void Writer::assignAddresses() {
sizeof(coff_section) * OutputSections.size();
SizeOfHeaders +=
Config->is64() ? sizeof(pe32plus_header) : sizeof(pe32_header);
- SizeOfHeaders = RoundUpToAlignment(SizeOfHeaders, SectorSize);
+ SizeOfHeaders = align(SizeOfHeaders, SectorSize);
uint64_t RVA = 0x1000; // The first page is kept unmapped.
FileSize = SizeOfHeaders;
// Move DISCARDABLE (or non-memory-mapped) sections to the end of file because
@@ -481,10 +480,10 @@ void Writer::assignAddresses() {
addBaserels(Sec);
Sec->setRVA(RVA);
Sec->setFileOffset(FileSize);
- RVA += RoundUpToAlignment(Sec->getVirtualSize(), PageSize);
- FileSize += RoundUpToAlignment(Sec->getRawSize(), SectorSize);
+ RVA += align(Sec->getVirtualSize(), PageSize);
+ FileSize += align(Sec->getRawSize(), SectorSize);
}
- SizeOfImage = SizeOfHeaders + RoundUpToAlignment(RVA - 0x1000, PageSize);
+ SizeOfImage = SizeOfHeaders + align(RVA - 0x1000, PageSize);
}
template <typename PEHeaderTy> void Writer::writeHeader() {
More information about the llvm-commits
mailing list