Rename Align -> Alignment.

I think it is me who named these variables, but I always find that
they are slightly confusing because align is a verb.
Adding four letters is worth it.

llvm-svn: 272984
This commit is contained in:
Rui Ueyama 2016-06-17 01:18:46 +00:00
parent ca2b3e7b5c
commit 424b408165
7 changed files with 27 additions and 27 deletions

View File

@ -36,7 +36,7 @@ InputSectionBase<ELFT>::InputSectionBase(elf::ObjectFile<ELFT> *File,
// The ELF spec states that a value of 0 means the section has
// no alignment constraits.
Align = std::max<uintX_t>(Header->sh_addralign, 1);
Alignment = std::max<uintX_t>(Header->sh_addralign, 1);
}
template <class ELFT> size_t InputSectionBase<ELFT>::getSize() const {
@ -382,7 +382,7 @@ template <class ELFT> void InputSection<ELFT>::writeTo(uint8_t *Buf) {
template <class ELFT>
void InputSection<ELFT>::replace(InputSection<ELFT> *Other) {
this->Align = std::max(this->Align, Other->Align);
this->Alignment = std::max(this->Alignment, Other->Alignment);
Other->Repl = this->Repl;
Other->Live = false;
}

View File

@ -50,7 +50,7 @@ public:
InputSectionBase(ObjectFile<ELFT> *File, const Elf_Shdr *Header,
Kind SectionKind);
OutputSectionBase<ELFT> *OutSec = nullptr;
uint32_t Align;
uint32_t Alignment;
// Used for garbage collection.
bool Live;

View File

@ -239,14 +239,14 @@ void LinkerScript<ELFT>::assignAddresses(
if ((Sec->getFlags() & SHF_TLS) && Sec->getType() == SHT_NOBITS) {
uintX_t TVA = Dot + ThreadBssOffset;
TVA = alignTo(TVA, Sec->getAlign());
TVA = alignTo(TVA, Sec->getAlignment());
Sec->setVA(TVA);
ThreadBssOffset = TVA - Dot + Sec->getSize();
continue;
}
if (Sec->getFlags() & SHF_ALLOC) {
Dot = alignTo(Dot, Sec->getAlign());
Dot = alignTo(Dot, Sec->getAlignment());
Sec->setVA(Dot);
Dot += Sec->getSize();
continue;

View File

@ -781,7 +781,7 @@ void OutputSection<ELFT>::addSection(InputSectionBase<ELFT> *C) {
auto *S = cast<InputSection<ELFT>>(C);
Sections.push_back(S);
S->OutSec = this;
this->updateAlign(S->Align);
this->updateAlignment(S->Alignment);
}
// If an input string is in the form of "foo.N" where N is a number,
@ -1019,7 +1019,7 @@ template <class ELFT>
void EhOutputSection<ELFT>::addSection(InputSectionBase<ELFT> *C) {
auto *Sec = cast<EhInputSection<ELFT>>(C);
Sec->OutSec = this;
this->updateAlign(Sec->Align);
this->updateAlignment(Sec->Alignment);
Sections.push_back(Sec);
// .eh_frame is a sequence of CIE or FDE records. This function
@ -1160,7 +1160,7 @@ template <class ELFT>
void MergeOutputSection<ELFT>::addSection(InputSectionBase<ELFT> *C) {
auto *Sec = cast<MergeInputSection<ELFT>>(C);
Sec->OutSec = this;
this->updateAlign(Sec->Align);
this->updateAlignment(Sec->Alignment);
this->Header.sh_entsize = Sec->getSectionHdr()->sh_entsize;
Sections.push_back(Sec);

View File

@ -77,15 +77,15 @@ public:
void setSize(uintX_t Val) { Header.sh_size = Val; }
uintX_t getFlags() const { return Header.sh_flags; }
uintX_t getFileOff() const { return Header.sh_offset; }
uintX_t getAlign() const {
uintX_t getAlignment() const {
// The ELF spec states that a value of 0 means the section has no alignment
// constraits.
return std::max<uintX_t>(Header.sh_addralign, 1);
}
uint32_t getType() const { return Header.sh_type; }
void updateAlign(uintX_t Align) {
if (Align > Header.sh_addralign)
Header.sh_addralign = Align;
void updateAlignment(uintX_t Alignment) {
if (Alignment > Header.sh_addralign)
Header.sh_addralign = Alignment;
}
// If true, this section will be page aligned on disk.

View File

@ -354,10 +354,10 @@ template <class ELFT> static void addCopyRelSymbol(SharedSymbol<ELFT> *SS) {
if (SymSize == 0)
fatal("cannot create a copy relocation for " + SS->getName());
uintX_t Align = getAlignment(SS);
uintX_t Off = alignTo(Out<ELFT>::Bss->getSize(), Align);
uintX_t Alignment = getAlignment(SS);
uintX_t Off = alignTo(Out<ELFT>::Bss->getSize(), Alignment);
Out<ELFT>::Bss->setSize(Off + SymSize);
Out<ELFT>::Bss->updateAlign(Align);
Out<ELFT>::Bss->updateAlignment(Alignment);
uintX_t Shndx = SS->Sym.st_shndx;
uintX_t Value = SS->Sym.st_value;
// Look through the DSO's dynamic symbol table for aliases and create a

View File

@ -124,7 +124,7 @@ template <class ELFT> void elf::writeResult(SymbolTable<ELFT> *Symtab) {
OutputSectionBase<ELFT> ElfHeader("", 0, SHF_ALLOC);
ElfHeader.setSize(sizeof(Elf_Ehdr));
OutputSectionBase<ELFT> ProgramHeaders("", 0, SHF_ALLOC);
ProgramHeaders.updateAlign(sizeof(uintX_t));
ProgramHeaders.updateAlignment(sizeof(uintX_t));
// Instantiate optional output sections if they are needed.
std::unique_ptr<BuildIdSection<ELFT>> BuildId;
@ -168,7 +168,7 @@ template <class ELFT> void elf::writeResult(SymbolTable<ELFT> *Symtab) {
MipsRldMap.reset(new OutputSection<ELFT>(".rld_map", SHT_PROGBITS,
SHF_ALLOC | SHF_WRITE));
MipsRldMap->setSize(sizeof(uintX_t));
MipsRldMap->updateAlign(sizeof(uintX_t));
MipsRldMap->updateAlignment(sizeof(uintX_t));
}
Out<ELFT>::Bss = &Bss;
@ -492,7 +492,7 @@ void Writer<ELFT>::addCommonSymbols(std::vector<DefinedCommon *> &Syms) {
uintX_t Off = Out<ELFT>::Bss->getSize();
for (DefinedCommon *C : Syms) {
Off = alignTo(Off, C->Alignment);
Out<ELFT>::Bss->updateAlign(C->Alignment);
Out<ELFT>::Bss->updateAlignment(C->Alignment);
C->OffsetInBss = Off;
Off += C->Size;
}
@ -793,7 +793,7 @@ template <class ELFT> void Writer<ELFT>::createSections() {
Sec->forEachInputSection([&](InputSectionBase<ELFT> *S) {
if (auto *IS = dyn_cast<InputSection<ELFT>>(S)) {
// Set OutSecOff so that scanRelocations can use it.
uintX_t Off = alignTo(Sec->getSize(), S->Align);
uintX_t Off = alignTo(Sec->getSize(), S->Alignment);
IS->OutSecOff = Off;
scanRelocations(*IS);
@ -1013,7 +1013,7 @@ template <class ELFT> void Writer<ELFT>::createPhdrs() {
Hdr.Last = Sec;
if (!Hdr.First)
Hdr.First = Sec;
Hdr.H.p_align = std::max<uintX_t>(Hdr.H.p_align, Sec->getAlign());
Hdr.H.p_align = std::max<uintX_t>(Hdr.H.p_align, Sec->getAlignment());
};
// The first phdr entry is PT_PHDR which describes the program header itself.
@ -1137,18 +1137,18 @@ template <class ELFT> void Writer<ELFT>::assignAddresses() {
uintX_t ThreadBssOffset = 0;
for (OutputSectionBase<ELFT> *Sec : OutputSections) {
uintX_t Align = Sec->getAlign();
uintX_t Alignment = Sec->getAlignment();
if (Sec->PageAlign)
Align = std::max<uintX_t>(Align, Target->PageSize);
Alignment = std::max<uintX_t>(Alignment, Target->PageSize);
// We only assign VAs to allocated sections.
if (needsPtLoad<ELFT>(Sec)) {
VA = alignTo(VA, Align);
VA = alignTo(VA, Alignment);
Sec->setVA(VA);
VA += Sec->getSize();
} else if (Sec->getFlags() & SHF_TLS && Sec->getType() == SHT_NOBITS) {
uintX_t TVA = VA + ThreadBssOffset;
TVA = alignTo(TVA, Align);
TVA = alignTo(TVA, Alignment);
Sec->setVA(TVA);
ThreadBssOffset = TVA - VA + Sec->getSize();
}
@ -1161,10 +1161,10 @@ template <class ELFT> void Writer<ELFT>::assignAddresses() {
// executables without any address adjustment.
template <class ELFT, class uintX_t>
static uintX_t getFileAlignment(uintX_t Off, OutputSectionBase<ELFT> *Sec) {
uintX_t Align = Sec->getAlign();
uintX_t Alignment = Sec->getAlignment();
if (Sec->PageAlign)
Align = std::max<uintX_t>(Align, Target->PageSize);
Off = alignTo(Off, Align);
Alignment = std::max<uintX_t>(Alignment, Target->PageSize);
Off = alignTo(Off, Alignment);
// Relocatable output does not have program headers
// and does not need any other offset adjusting.