[lld] r222975 - [ELF] Rename align2 to alignment.
Shankar Easwaran
shankare at codeaurora.org
Sat Nov 29 20:17:06 PST 2014
Author: shankare
Date: Sat Nov 29 22:17:06 2014
New Revision: 222975
URL: http://llvm.org/viewvc/llvm-project?rev=222975&view=rev
Log:
[ELF] Rename align2 to alignment.
No change in functionality.
Modified:
lld/trunk/lib/ReaderWriter/ELF/Chunk.h
lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h
lld/trunk/lib/ReaderWriter/ELF/HeaderChunks.h
lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonSectionChunks.h
lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h
lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h
lld/trunk/lib/ReaderWriter/ELF/SegmentChunks.h
Modified: lld/trunk/lib/ReaderWriter/ELF/Chunk.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Chunk.h?rev=222975&r1=222974&r2=222975&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Chunk.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Chunk.h Sat Nov 29 22:17:06 2014
@@ -45,7 +45,7 @@ public:
enum ContentType : uint8_t{ Unknown, Header, Code, Data, Note, TLS };
Chunk(StringRef name, Kind kind, const ELFLinkingContext &context)
- : _name(name), _kind(kind), _fsize(0), _msize(0), _align2(0), _order(0),
+ : _name(name), _kind(kind), _fsize(0), _msize(0), _alignment(0), _order(0),
_ordinal(1), _start(0), _fileoffset(0), _context(context) {}
virtual ~Chunk() {}
// The name of the chunk
@@ -54,8 +54,8 @@ public:
Kind kind() const { return _kind; }
virtual uint64_t fileSize() const { return _fsize; }
virtual void setFileSize(uint64_t sz) { _fsize = sz; }
- virtual void setAlign(uint64_t align) { _align2 = align; }
- virtual uint64_t align2() const { return _align2; }
+ virtual void setAlign(uint64_t align) { _alignment = align; }
+ virtual uint64_t alignment() const { return _alignment; }
// The ordinal value of the chunk
uint64_t ordinal() const { return _ordinal;}
@@ -87,7 +87,7 @@ protected:
Kind _kind;
uint64_t _fsize;
uint64_t _msize;
- uint64_t _align2;
+ uint64_t _alignment;
uint32_t _order;
uint64_t _ordinal;
uint64_t _start;
Modified: lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h?rev=222975&r1=222974&r2=222975&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/DefaultLayout.h Sat Nov 29 22:17:06 2014
@@ -762,7 +762,7 @@ DefaultLayout<ELFT>::assignVirtualAddres
for (auto si : _segments) {
if (si->segmentType() == llvm::ELF::PT_LOAD) {
firstLoadSegment = si;
- si->firstSection()->setAlign(si->align2());
+ si->firstSection()->setAlign(si->alignment());
break;
}
}
@@ -867,7 +867,7 @@ void DefaultLayout<ELFT>::assignFileOffs
section = dyn_cast<Section<ELFT>>(si);
if (section && DefaultLayout<ELFT>::hasOutputSegment(section))
continue;
- fileoffset = llvm::RoundUpToAlignment(fileoffset, si->align2());
+ fileoffset = llvm::RoundUpToAlignment(fileoffset, si->alignment());
si->setFileOffset(fileoffset);
si->setVirtualAddr(0);
fileoffset += si->fileSize();
Modified: lld/trunk/lib/ReaderWriter/ELF/HeaderChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/HeaderChunks.h?rev=222975&r1=222974&r2=222975&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/HeaderChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/HeaderChunks.h Sat Nov 29 22:17:06 2014
@@ -74,7 +74,7 @@ private:
template <class ELFT>
ELFHeader<ELFT>::ELFHeader(const ELFLinkingContext &context)
: Chunk<ELFT>("elfhdr", Chunk<ELFT>::Kind::ELFHeader, context) {
- this->_align2 = ELFT::Is64Bits ? 8 : 4;
+ this->_alignment = ELFT::Is64Bits ? 8 : 4;
this->_fsize = sizeof(Elf_Ehdr);
this->_msize = sizeof(Elf_Ehdr);
memset(_eh.e_ident, 0, llvm::ELF::EI_NIDENT);
@@ -126,7 +126,7 @@ public:
ProgramHeader(const ELFLinkingContext &context)
: Chunk<ELFT>("elfphdr", Chunk<ELFT>::Kind::ProgramHeader, context) {
- this->_align2 = ELFT::Is64Bits ? 8 : 4;
+ this->_alignment = ELFT::Is64Bits ? 8 : 4;
resetProgramHeaders();
}
@@ -210,7 +210,7 @@ bool ProgramHeader<ELFT>::addSegment(Seg
phdr->p_filesz = segment->fileSize();
phdr->p_memsz = segment->memSize();
phdr->p_flags = segment->flags();
- phdr->p_align = segment->align2();
+ phdr->p_align = segment->alignment();
this->_fsize = fileSize();
this->_msize = this->_fsize;
return allocatedNew;
@@ -226,9 +226,9 @@ bool ProgramHeader<ELFT>::addSegment(Seg
phdr->p_filesz = slice->fileSize();
phdr->p_memsz = slice->memSize();
phdr->p_flags = segment->flags();
- phdr->p_align = slice->align2();
+ phdr->p_align = slice->alignment();
uint64_t segPageSize = segment->pageSize();
- uint64_t sliceAlign = slice->align2();
+ uint64_t sliceAlign = slice->alignment();
// Alignment of PT_LOAD segments are set to the page size, but if the
// alignment of the slice is greater than the page size, set the alignment
// of the segment appropriately.
@@ -238,7 +238,7 @@ bool ProgramHeader<ELFT>::addSegment(Seg
? (segPageSize < sliceAlign) ? sliceAlign : segPageSize
: sliceAlign;
} else
- phdr->p_align = slice->align2();
+ phdr->p_align = slice->alignment();
}
this->_fsize = fileSize();
this->_msize = this->_fsize;
@@ -308,7 +308,7 @@ SectionHeader<ELFT>::SectionHeader(const
int32_t order)
: Chunk<ELFT>("shdr", Chunk<ELFT>::Kind::SectionHeader, context) {
this->_fsize = 0;
- this->_align2 = 8;
+ this->_alignment = 8;
this->setOrder(order);
// The first element in the list is always NULL
Elf_Shdr *nullshdr = new (_sectionAllocate.Allocate<Elf_Shdr>()) Elf_Shdr;
@@ -331,7 +331,7 @@ void SectionHeader<ELFT>::appendSection(
shdr->sh_size = section->fileSize();
shdr->sh_link = section->link();
shdr->sh_info = section->shinfo();
- shdr->sh_addralign = section->align2();
+ shdr->sh_addralign = section->alignment();
shdr->sh_entsize = section->entsize();
_sectionInfo.push_back(shdr);
}
@@ -347,7 +347,7 @@ SectionHeader<ELFT>::updateSection(Secti
shdr->sh_size = section->fileSize();
shdr->sh_link = section->getLink();
shdr->sh_info = section->getInfo();
- shdr->sh_addralign = section->align2();
+ shdr->sh_addralign = section->alignment();
shdr->sh_entsize = section->getEntSize();
}
Modified: lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonSectionChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonSectionChunks.h?rev=222975&r1=222974&r2=222975&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonSectionChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Hexagon/HexagonSectionChunks.h Sat Nov 29 22:17:06 2014
@@ -26,7 +26,7 @@ public:
HexagonTargetLayout<HexagonELFType>::ORDER_SDATA) {
this->_type = SHT_PROGBITS;
this->_flags = SHF_ALLOC | SHF_WRITE;
- this->_align2 = 4096;
+ this->_alignment = 4096;
}
/// \brief Finalize the section contents before writing
@@ -38,12 +38,12 @@ public:
const lld::AtomLayout &appendAtom(const Atom *atom) {
const DefinedAtom *definedAtom = cast<DefinedAtom>(atom);
DefinedAtom::Alignment atomAlign = definedAtom->alignment();
- uint64_t align2 = 1u << atomAlign.powerOf2;
+ uint64_t alignment = 1u << atomAlign.powerOf2;
this->_atoms.push_back(new (this->_alloc) lld::AtomLayout(atom, 0, 0));
// Set the section alignment to the largest alignment
// std::max doesn't support uint64_t
- if (this->_align2 < align2)
- this->_align2 = align2;
+ if (this->_alignment < alignment)
+ this->_alignment = alignment;
return *(this->_atoms.back());
}
@@ -57,15 +57,15 @@ void SDataSection<HexagonELFType>::doPre
const lld::AtomLayout * B) {
const DefinedAtom *definedAtomA = cast<DefinedAtom>(A->_atom);
const DefinedAtom *definedAtomB = cast<DefinedAtom>(B->_atom);
- int64_t align2A = 1 << definedAtomA->alignment().powerOf2;
- int64_t align2B = 1 << definedAtomB->alignment().powerOf2;
- if (align2A == align2B) {
+ int64_t alignmentA = 1 << definedAtomA->alignment().powerOf2;
+ int64_t alignmentB = 1 << definedAtomB->alignment().powerOf2;
+ if (alignmentA == alignmentB) {
if (definedAtomA->merge() == DefinedAtom::mergeAsTentative)
return false;
if (definedAtomB->merge() == DefinedAtom::mergeAsTentative)
return true;
}
- return align2A < align2B;
+ return alignmentA < alignmentB;
});
// Set the fileOffset, and the appropriate size of the section
Modified: lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h?rev=222975&r1=222974&r2=222975&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/Mips/MipsSectionChunks.h Sat Nov 29 22:17:06 2014
@@ -24,7 +24,7 @@ public:
MipsTargetLayout<ELFType>::ORDER_GOT),
_hasNonLocal(false), _localCount(0) {
this->_flags |= SHF_MIPS_GPREL;
- this->_align2 = 4;
+ this->_alignment = 4;
}
/// \brief Number of local GOT entries.
Modified: lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h?rev=222975&r1=222974&r2=222975&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/SectionChunks.h Sat Nov 29 22:17:06 2014
@@ -107,9 +107,9 @@ public:
c->kind() == Chunk<ELFT>::Kind::AtomSection;
}
- uint64_t align2() const override {
- return _isFirstSectionInOutputSection ? _outputSection->align2()
- : this->_align2;
+ uint64_t alignment() const override {
+ return _isFirstSectionInOutputSection ? _outputSection->alignment()
+ : this->_alignment;
}
virtual StringRef inputSectionName() const { return _inputSectionName; }
@@ -277,14 +277,14 @@ template <class ELFT>
uint64_t AtomSection<ELFT>::alignOffset(uint64_t offset,
DefinedAtom::Alignment &atomAlign) {
uint64_t requiredModulus = atomAlign.modulus;
- uint64_t align2 = 1u << atomAlign.powerOf2;
- uint64_t currentModulus = (offset % align2);
+ uint64_t alignment = 1u << atomAlign.powerOf2;
+ uint64_t currentModulus = (offset % alignment);
uint64_t retOffset = offset;
if (currentModulus != requiredModulus) {
if (requiredModulus > currentModulus)
retOffset += requiredModulus - currentModulus;
else
- retOffset += align2 + requiredModulus - currentModulus;
+ retOffset += alignment + requiredModulus - currentModulus;
}
return retOffset;
}
@@ -297,7 +297,7 @@ const lld::AtomLayout &AtomSection<ELFT>
const DefinedAtom *definedAtom = cast<DefinedAtom>(atom);
DefinedAtom::Alignment atomAlign = definedAtom->alignment();
- uint64_t align2 = 1u << atomAlign.powerOf2;
+ uint64_t alignment = 1u << atomAlign.powerOf2;
// Align the atom to the required modulus/ align the file offset and the
// memory offset separately this is required so that BSS symbols are handled
// properly as the BSS symbols only occupy memory size and not file size
@@ -342,8 +342,8 @@ const lld::AtomLayout &AtomSection<ELFT>
}
// Set the section alignment to the largest alignment
// std::max doesn't support uint64_t
- if (this->_align2 < align2)
- this->_align2 = align2;
+ if (this->_alignment < alignment)
+ this->_alignment = alignment;
return *_atoms.back();
}
@@ -467,7 +467,7 @@ public:
inline int64_t shinfo() const { return _shInfo; }
- inline uint64_t align2() const { return _align2; }
+ inline uint64_t alignment() const { return _alignment; }
inline int64_t link() const { return _link; }
@@ -501,7 +501,7 @@ private:
int64_t _shInfo;
int64_t _entSize;
int64_t _link;
- uint64_t _align2;
+ uint64_t _alignment;
int64_t _kind;
int64_t _type;
bool _isLoadableSection;
@@ -513,11 +513,11 @@ template <class ELFT>
OutputSection<ELFT>::OutputSection(StringRef name)
: _name(name), _hasSegment(false), _ordinal(0), _flags(0), _size(0),
_memSize(0), _fileOffset(0), _virtualAddr(0), _shInfo(0), _entSize(0),
- _link(0), _align2(0), _kind(0), _type(0), _isLoadableSection(false) {}
+ _link(0), _alignment(0), _kind(0), _type(0), _isLoadableSection(false) {}
template <class ELFT> void OutputSection<ELFT>::appendSection(Chunk<ELFT> *c) {
- if (c->align2() > _align2)
- _align2 = c->align2();
+ if (c->alignment() > _alignment)
+ _alignment = c->alignment();
if (const auto section = dyn_cast<Section<ELFT>>(c)) {
assert(!_link && "Section already has a link!");
_link = section->getLink();
@@ -575,7 +575,7 @@ StringTable<ELFT>::StringTable(const ELF
// add an empty string
_strings.push_back("");
this->_fsize = 1;
- this->_align2 = 1;
+ this->_alignment = 1;
this->setOrder(order);
this->_type = SHT_STRTAB;
if (dynamic) {
@@ -701,7 +701,7 @@ SymbolTable<ELFT>::SymbolTable(const ELF
_symbolTable.push_back(SymbolEntry(nullptr, symbol, nullptr));
this->_entSize = sizeof(Elf_Sym);
this->_fsize = sizeof(Elf_Sym);
- this->_align2 = sizeof(Elf_Addr);
+ this->_alignment = sizeof(Elf_Addr);
this->_type = SHT_SYMTAB;
}
@@ -930,7 +930,7 @@ public:
this->setOrder(order);
this->_flags = SHF_ALLOC;
// Set the alignment properly depending on the target architecture
- this->_align2 = ELFT::Is64Bits ? 8 : 4;
+ this->_alignment = ELFT::Is64Bits ? 8 : 4;
if (context.isRelaOutputFormat()) {
this->_entSize = sizeof(Elf_Rela);
this->_type = SHT_RELA;
@@ -1045,7 +1045,7 @@ public:
: Section<ELFT>(context, str, "DynamicSection"), _layout(layout) {
this->setOrder(order);
this->_entSize = sizeof(Elf_Dyn);
- this->_align2 = ELFT::Is64Bits ? 8 : 4;
+ this->_alignment = ELFT::Is64Bits ? 8 : 4;
// Reserve space for the DT_NULL entry.
this->_fsize = sizeof(Elf_Dyn);
this->_msize = sizeof(Elf_Dyn);
@@ -1227,7 +1227,7 @@ public:
StringRef interp)
: Section<ELFT>(context, str, "Dynamic:Interp"), _interp(interp) {
this->setOrder(order);
- this->_align2 = 1;
+ this->_alignment = 1;
// + 1 for null term.
this->_fsize = interp.size() + 1;
this->_msize = this->_fsize;
@@ -1279,7 +1279,7 @@ public:
this->_entSize = 4;
this->_type = SHT_HASH;
this->_flags = SHF_ALLOC;
- this->_align2 = ELFT::Is64Bits ? 8 : 4;
+ this->_alignment = ELFT::Is64Bits ? 8 : 4;
this->_fsize = 0;
this->_msize = 0;
}
@@ -1383,7 +1383,7 @@ public:
this->_entSize = 0;
this->_type = SHT_PROGBITS;
this->_flags = SHF_ALLOC;
- this->_align2 = ELFT::Is64Bits ? 8 : 4;
+ this->_alignment = ELFT::Is64Bits ? 8 : 4;
// Minimum size for empty .eh_frame_hdr.
this->_fsize = 1 + 1 + 1 + 1 + 4;
this->_msize = this->_fsize;
Modified: lld/trunk/lib/ReaderWriter/ELF/SegmentChunks.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/SegmentChunks.h?rev=222975&r1=222974&r2=222975&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/SegmentChunks.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/SegmentChunks.h Sat Nov 29 22:17:06 2014
@@ -70,13 +70,13 @@ public:
inline uint64_t memSize() const { return _memSize; }
// Return the alignment of the slice
- inline uint64_t align2() const { return _align2; }
+ inline uint64_t alignment() const { return _alignment; }
inline void setMemSize(uint64_t memsz) { _memSize = memsz; }
inline void setVirtualAddr(uint64_t addr) { _addr = addr; }
- inline void setAlign(uint64_t align) { _align2 = align; }
+ inline void setAlign(uint64_t align) { _alignment = align; }
static bool compare_slices(SegmentSlice<ELFT> *a, SegmentSlice<ELFT> *b) {
return a->startSection() < b->startSection();
@@ -91,7 +91,7 @@ private:
int32_t _startSection;
uint64_t _addr;
uint64_t _offset;
- uint64_t _align2;
+ uint64_t _alignment;
uint64_t _fsize;
uint64_t _memSize;
};
@@ -286,7 +286,7 @@ template <class ELFT> class ProgramHeade
public:
ProgramHeaderSegment(const ELFLinkingContext &context)
: Segment<ELFT>(context, "PHDR", llvm::ELF::PT_PHDR) {
- this->_align2 = 8;
+ this->_alignment = 8;
this->_flags = (llvm::ELF::SHF_ALLOC | llvm::ELF::SHF_EXECINSTR);
}
@@ -316,7 +316,7 @@ Segment<ELFT>::Segment(const ELFLinkingC
const Layout::SegmentType type)
: Chunk<ELFT>(name, Chunk<ELFT>::Kind::ELFSegment, context),
_segmentType(type), _flags(0), _atomflags(0) {
- this->_align2 = 0;
+ this->_alignment = 0;
this->_fsize = 0;
_outputMagic = context.getOutputMagic();
}
@@ -344,8 +344,8 @@ template <class ELFT> void Segment<ELFT>
_flags |= section->getFlags();
if (_atomflags < toAtomPerms(_flags))
_atomflags = toAtomPerms(_flags);
- if (this->_align2 < section->align2())
- this->_align2 = section->align2();
+ if (this->_alignment < section->alignment())
+ this->_alignment = section->alignment();
}
template <class ELFT>
@@ -407,7 +407,7 @@ void Segment<ELFT>::assignFileOffsets(ui
bool isFirstSection = true;
for (auto section : slice->sections()) {
// Align fileoffset to the alignment of the section.
- fileOffset = llvm::RoundUpToAlignment(fileOffset, section->align2());
+ fileOffset = llvm::RoundUpToAlignment(fileOffset, section->alignment());
// If the linker outputmagic is set to OutputMagic::NMAGIC, align the Data
// to a page boundary
if (isFirstSection &&
@@ -491,16 +491,16 @@ template <class ELFT> void Segment<ELFT>
isDataPageAlignedForNMagic = true;
}
// align the startOffset to the section alignment
- uint64_t newAddr = llvm::RoundUpToAlignment(startAddr, (*si)->align2());
+ uint64_t newAddr = llvm::RoundUpToAlignment(startAddr, (*si)->alignment());
curSliceAddress = newAddr;
- sliceAlign = (*si)->align2();
+ sliceAlign = (*si)->alignment();
(*si)->setVirtualAddr(curSliceAddress);
// Handle TLS.
if (auto section = dyn_cast<Section<ELFT>>(*si)) {
if (section->getSegmentType() == llvm::ELF::PT_TLS) {
tlsStartAddr =
- llvm::RoundUpToAlignment(tlsStartAddr, (*si)->align2());
+ llvm::RoundUpToAlignment(tlsStartAddr, (*si)->alignment());
section->assignVirtualAddress(tlsStartAddr);
tlsStartAddr += (*si)->memSize();
} else {
@@ -523,7 +523,7 @@ template <class ELFT> void Segment<ELFT>
llvm::RoundUpToAlignment(curAddr, this->_context.getPageSize());
isDataPageAlignedForNMagic = true;
}
- uint64_t newAddr = llvm::RoundUpToAlignment(curAddr, (*si)->align2());
+ uint64_t newAddr = llvm::RoundUpToAlignment(curAddr, (*si)->alignment());
Section<ELFT> *sec = dyn_cast<Section<ELFT>>(*si);
StringRef curOutputSectionName =
sec ? sec->outputSectionName() : (*si)->name();
@@ -563,16 +563,16 @@ template <class ELFT> void Segment<ELFT>
if (auto section = dyn_cast<Section<ELFT>>(*si))
section->assignVirtualAddress(newAddr);
curSliceSize = newAddr - curSliceAddress + (*si)->memSize();
- sliceAlign = (*si)->align2();
+ sliceAlign = (*si)->alignment();
} else {
- if (sliceAlign < (*si)->align2())
- sliceAlign = (*si)->align2();
+ if (sliceAlign < (*si)->alignment())
+ sliceAlign = (*si)->alignment();
(*si)->setVirtualAddr(newAddr);
// Handle TLS.
if (auto section = dyn_cast<Section<ELFT>>(*si)) {
if (section->getSegmentType() == llvm::ELF::PT_TLS) {
tlsStartAddr =
- llvm::RoundUpToAlignment(tlsStartAddr, (*si)->align2());
+ llvm::RoundUpToAlignment(tlsStartAddr, (*si)->alignment());
section->assignVirtualAddress(tlsStartAddr);
tlsStartAddr += (*si)->memSize();
} else {
More information about the llvm-commits
mailing list