[lld] 08e2a76 - [lld][NFC] rename ELF alignment into addralign
Guillaume Chatelet via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 1 08:20:26 PST 2022
Author: Guillaume Chatelet
Date: 2022-12-01T16:20:12Z
New Revision: 08e2a7638153e5917354d7575699d15b34c5ed4a
URL: https://github.com/llvm/llvm-project/commit/08e2a7638153e5917354d7575699d15b34c5ed4a
DIFF: https://github.com/llvm/llvm-project/commit/08e2a7638153e5917354d7575699d15b34c5ed4a.diff
LOG: [lld][NFC] rename ELF alignment into addralign
Added:
Modified:
lld/ELF/InputFiles.cpp
lld/ELF/InputSection.cpp
lld/ELF/InputSection.h
lld/ELF/LinkerScript.cpp
lld/ELF/MapFile.cpp
lld/ELF/OutputSections.cpp
lld/ELF/Relocations.cpp
lld/ELF/ScriptParser.cpp
lld/ELF/SyntheticSections.cpp
lld/ELF/SyntheticSections.h
lld/ELF/Writer.cpp
Removed:
################################################################################
diff --git a/lld/ELF/InputFiles.cpp b/lld/ELF/InputFiles.cpp
index af441953b7bec..6aca878987ce4 100644
--- a/lld/ELF/InputFiles.cpp
+++ b/lld/ELF/InputFiles.cpp
@@ -810,7 +810,7 @@ void ObjFile<ELFT>::initializeSections(bool ignoreComdats,
// is acceptable because section merging is optional.
if (auto *ms = dyn_cast<MergeInputSection>(s)) {
s = makeThreadLocal<InputSection>(
- ms->file, ms->flags, ms->type, ms->alignment,
+ ms->file, ms->flags, ms->type, ms->addralign,
ms->contentMaybeDecompress(), ms->name);
sections[info] = s;
}
diff --git a/lld/ELF/InputSection.cpp b/lld/ELF/InputSection.cpp
index 9eff81b4ce0c7..2bbe6433a7a4e 100644
--- a/lld/ELF/InputSection.cpp
+++ b/lld/ELF/InputSection.cpp
@@ -51,9 +51,9 @@ static ArrayRef<uint8_t> getSectionContents(ObjFile<ELFT> &file,
InputSectionBase::InputSectionBase(InputFile *file, uint64_t flags,
uint32_t type, uint64_t entsize,
uint32_t link, uint32_t info,
- uint32_t alignment, ArrayRef<uint8_t> data,
+ uint32_t addralign, ArrayRef<uint8_t> data,
StringRef name, Kind sectionKind)
- : SectionBase(sectionKind, name, flags, entsize, alignment, type, info,
+ : SectionBase(sectionKind, name, flags, entsize, addralign, type, info,
link),
file(file), content_(data.data()), size(data.size()) {
// In order to reduce memory allocation, we assume that mergeable
@@ -64,10 +64,10 @@ InputSectionBase::InputSectionBase(InputFile *file, uint64_t flags,
// The ELF spec states that a value of 0 means the section has
// no alignment constraints.
- uint32_t v = std::max<uint32_t>(alignment, 1);
+ uint32_t v = std::max<uint32_t>(addralign, 1);
if (!isPowerOf2_64(v))
fatal(toString(this) + ": sh_addralign is not a power of 2");
- this->alignment = v;
+ this->addralign = v;
// If SHF_COMPRESSED is set, parse the header. The legacy .zdebug format is no
// longer supported.
@@ -231,7 +231,7 @@ template <typename ELFT> void InputSectionBase::parseCompressedHeader() {
compressed = true;
compressedSize = size;
size = hdr->ch_size;
- alignment = std::max<uint32_t>(hdr->ch_addralign, 1);
+ addralign = std::max<uint32_t>(hdr->ch_addralign, 1);
}
InputSection *InputSectionBase::getLinkOrderDep() const {
@@ -309,10 +309,10 @@ std::string InputSectionBase::getObjMsg(uint64_t off) {
InputSection InputSection::discarded(nullptr, 0, 0, 0, ArrayRef<uint8_t>(), "");
InputSection::InputSection(InputFile *f, uint64_t flags, uint32_t type,
- uint32_t alignment, ArrayRef<uint8_t> data,
+ uint32_t addralign, ArrayRef<uint8_t> data,
StringRef name, Kind k)
: InputSectionBase(f, flags, type,
- /*Entsize*/ 0, /*Link*/ 0, /*Info*/ 0, alignment, data,
+ /*Entsize*/ 0, /*Link*/ 0, /*Info*/ 0, addralign, data,
name, k) {}
template <class ELFT>
@@ -1124,7 +1124,7 @@ template <class ELFT> void InputSection::writeTo(uint8_t *buf) {
}
void InputSection::replace(InputSection *other) {
- alignment = std::max(alignment, other->alignment);
+ addralign = std::max(addralign, other->addralign);
// When a section is replaced with another section that was allocated to
// another partition, the replacement section (and its associated sections)
diff --git a/lld/ELF/InputSection.h b/lld/ELF/InputSection.h
index e562f6f735583..26b6b4af00f5c 100644
--- a/lld/ELF/InputSection.h
+++ b/lld/ELF/InputSection.h
@@ -71,7 +71,7 @@ class SectionBase {
// These corresponds to the fields in Elf_Shdr.
uint64_t flags;
- uint32_t alignment;
+ uint32_t addralign;
uint32_t entsize;
uint32_t link;
uint32_t info;
@@ -93,10 +93,10 @@ class SectionBase {
protected:
constexpr SectionBase(Kind sectionKind, StringRef name, uint64_t flags,
- uint32_t entsize, uint32_t alignment, uint32_t type,
+ uint32_t entsize, uint32_t addralign, uint32_t type,
uint32_t info, uint32_t link)
: sectionKind(sectionKind), bss(false), keepUnique(false), type(type),
- name(name), flags(flags), alignment(alignment), entsize(entsize),
+ name(name), flags(flags), addralign(addralign), entsize(entsize),
link(link), info(info) {}
};
@@ -111,7 +111,7 @@ class InputSectionBase : public SectionBase {
InputSectionBase(InputFile *file, uint64_t flags, uint32_t type,
uint64_t entsize, uint32_t link, uint32_t info,
- uint32_t alignment, ArrayRef<uint8_t> data, StringRef name,
+ uint32_t addralign, ArrayRef<uint8_t> data, StringRef name,
Kind sectionKind);
static bool classof(const SectionBase *s) { return s->kind() != Output; }
@@ -352,7 +352,7 @@ class EhInputSection : public InputSectionBase {
// .eh_frame. It also includes the synthetic sections themselves.
class InputSection : public InputSectionBase {
public:
- InputSection(InputFile *f, uint64_t flags, uint32_t type, uint32_t alignment,
+ InputSection(InputFile *f, uint64_t flags, uint32_t type, uint32_t addralign,
ArrayRef<uint8_t> data, StringRef name, Kind k = Regular);
template <class ELFT>
InputSection(ObjFile<ELFT> &f, const typename ELFT::Shdr &header,
@@ -405,9 +405,9 @@ static_assert(sizeof(InputSection) <= 152, "InputSection is too big");
class SyntheticSection : public InputSection {
public:
- SyntheticSection(uint64_t flags, uint32_t type, uint32_t alignment,
+ SyntheticSection(uint64_t flags, uint32_t type, uint32_t addralign,
StringRef name)
- : InputSection(nullptr, flags, type, alignment, {}, name,
+ : InputSection(nullptr, flags, type, addralign, {}, name,
InputSectionBase::Synthetic) {}
virtual ~SyntheticSection() = default;
diff --git a/lld/ELF/LinkerScript.cpp b/lld/ELF/LinkerScript.cpp
index 814794180d2c9..668a79b5edd7f 100644
--- a/lld/ELF/LinkerScript.cpp
+++ b/lld/ELF/LinkerScript.cpp
@@ -438,7 +438,7 @@ static void sortSections(MutableArrayRef<InputSectionBase *> vec,
// ">" is not a mistake. Sections with larger alignments are placed
// before sections with smaller alignments in order to reduce the
// amount of padding necessary. This is compatible with GNU.
- return a->alignment > b->alignment;
+ return a->addralign > b->addralign;
};
auto nameComparator = [](InputSectionBase *a, InputSectionBase *b) {
return a->name < b->name;
@@ -633,7 +633,7 @@ void LinkerScript::processSectionCommands() {
if (osec->subalignExpr) {
uint32_t subalign = osec->subalignExpr().getValue();
for (InputSectionBase *s : v)
- s->alignment = subalign;
+ s->addralign = subalign;
}
// Set the partition field the same way OutputSection::recordSection()
@@ -996,7 +996,7 @@ void LinkerScript::assignOffsets(OutputSection *sec) {
// sec->alignment is the max of ALIGN and the maximum of input
// section alignments.
const uint64_t pos = dot;
- dot = alignToPowerOf2(dot, sec->alignment);
+ dot = alignToPowerOf2(dot, sec->addralign);
sec->addr = dot;
expandMemoryRegions(dot - pos);
}
@@ -1010,7 +1010,7 @@ void LinkerScript::assignOffsets(OutputSection *sec) {
if (sec->lmaExpr) {
state->lmaOffset = sec->lmaExpr().getValue() - dot;
} else if (MemoryRegion *mr = sec->lmaRegion) {
- uint64_t lmaStart = alignToPowerOf2(mr->curPos, sec->alignment);
+ uint64_t lmaStart = alignToPowerOf2(mr->curPos, sec->addralign);
if (mr->curPos < lmaStart)
expandMemoryRegion(mr, lmaStart - mr->curPos, sec->name);
state->lmaOffset = lmaStart - dot;
@@ -1053,7 +1053,7 @@ void LinkerScript::assignOffsets(OutputSection *sec) {
for (InputSection *isec : cast<InputSectionDescription>(cmd)->sections) {
assert(isec->getParent() == sec);
const uint64_t pos = dot;
- dot = alignToPowerOf2(dot, isec->alignment);
+ dot = alignToPowerOf2(dot, isec->addralign);
isec->outSecOff = dot - sec->addr;
dot += isec->getSize();
@@ -1152,8 +1152,8 @@ void LinkerScript::adjustOutputSections() {
// Handle align (e.g. ".foo : ALIGN(16) { ... }").
if (sec->alignExpr)
- sec->alignment =
- std::max<uint32_t>(sec->alignment, sec->alignExpr().getValue());
+ sec->addralign =
+ std::max<uint32_t>(sec->addralign, sec->alignExpr().getValue());
bool isEmpty = (getFirstInputSection(sec) == nullptr);
bool discardable = isEmpty && isDiscardable(*sec);
diff --git a/lld/ELF/MapFile.cpp b/lld/ELF/MapFile.cpp
index 03150881b9abf..e28656cd38dca 100644
--- a/lld/ELF/MapFile.cpp
+++ b/lld/ELF/MapFile.cpp
@@ -169,7 +169,7 @@ static void writeMapFile(raw_fd_ostream &os) {
}
osec = &cast<OutputDesc>(cmd)->osec;
- writeHeader(os, osec->addr, osec->getLMA(), osec->size, osec->alignment);
+ writeHeader(os, osec->addr, osec->getLMA(), osec->size, osec->addralign);
os << osec->name << '\n';
// Dump symbols for each input section.
@@ -182,7 +182,7 @@ static void writeMapFile(raw_fd_ostream &os) {
}
writeHeader(os, isec->getVA(), osec->getLMA() + isec->outSecOff,
- isec->getSize(), isec->alignment);
+ isec->getSize(), isec->addralign);
os << indent8 << toString(isec) << '\n';
for (Symbol *sym : llvm::make_first_range(sectionSyms[isec]))
os << symStr[sym] << '\n';
diff --git a/lld/ELF/OutputSections.cpp b/lld/ELF/OutputSections.cpp
index 6c78d1358dffc..0892b71fc6ae8 100644
--- a/lld/ELF/OutputSections.cpp
+++ b/lld/ELF/OutputSections.cpp
@@ -60,7 +60,7 @@ uint32_t OutputSection::getPhdrFlags() const {
template <class ELFT>
void OutputSection::writeHeaderTo(typename ELFT::Shdr *shdr) {
shdr->sh_entsize = entsize;
- shdr->sh_addralign = alignment;
+ shdr->sh_addralign = addralign;
shdr->sh_type = type;
shdr->sh_offset = offset;
shdr->sh_flags = flags;
@@ -157,7 +157,7 @@ void OutputSection::commitSection(InputSection *isec) {
if (nonAlloc)
flags &= ~(uint64_t)SHF_ALLOC;
- alignment = std::max(alignment, isec->alignment);
+ addralign = std::max(addralign, isec->addralign);
// If this section contains a table of fixed-size entries, sh_entsize
// holds the element size. If it contains elements of
diff erent size we
@@ -169,10 +169,10 @@ void OutputSection::commitSection(InputSection *isec) {
static MergeSyntheticSection *createMergeSynthetic(StringRef name,
uint32_t type,
uint64_t flags,
- uint32_t alignment) {
+ uint32_t addralign) {
if ((flags & SHF_STRINGS) && config->optimize >= 2)
- return make<MergeTailSection>(name, type, flags, alignment);
- return make<MergeNoTailSection>(name, type, flags, alignment);
+ return make<MergeTailSection>(name, type, flags, addralign);
+ return make<MergeNoTailSection>(name, type, flags, addralign);
}
// This function scans over the InputSectionBase list sectionBases to create
@@ -213,11 +213,11 @@ void OutputSection::finalizeInputSections() {
//
// SHF_STRINGS section with
diff erent alignments should not be merged.
return sec->flags == ms->flags && sec->entsize == ms->entsize &&
- (sec->alignment == ms->alignment || !(sec->flags & SHF_STRINGS));
+ (sec->addralign == ms->addralign || !(sec->flags & SHF_STRINGS));
});
if (i == mergeSections.end()) {
MergeSyntheticSection *syn =
- createMergeSynthetic(name, ms->type, ms->flags, ms->alignment);
+ createMergeSynthetic(name, ms->type, ms->flags, ms->addralign);
mergeSections.push_back(syn);
i = std::prev(mergeSections.end());
syn->entsize = ms->entsize;
@@ -452,7 +452,7 @@ void OutputSection::writeTo(uint8_t *buf, parallel::TaskGroup &tg) {
if (compressed.shards) {
auto *chdr = reinterpret_cast<typename ELFT::Chdr *>(buf);
chdr->ch_size = compressed.uncompressedSize;
- chdr->ch_addralign = alignment;
+ chdr->ch_addralign = addralign;
buf += sizeof(*chdr);
if (config->compressDebugSections == DebugCompressionType::Zstd) {
chdr->ch_type = ELFCOMPRESS_ZSTD;
diff --git a/lld/ELF/Relocations.cpp b/lld/ELF/Relocations.cpp
index bcb65c667ad50..6ef7a328e96df 100644
--- a/lld/ELF/Relocations.cpp
+++ b/lld/ELF/Relocations.cpp
@@ -855,7 +855,7 @@ static void addRelativeReloc(InputSectionBase &isec, uint64_t offsetInSec,
// relrDyn sections don't support odd offsets. Also, relrDyn sections
// don't store the addend values, so we must write it to the relocated
// address.
- if (part.relrDyn && isec.alignment >= 2 && offsetInSec % 2 == 0) {
+ if (part.relrDyn && isec.addralign >= 2 && offsetInSec % 2 == 0) {
isec.addReloc({expr, type, offsetInSec, addend, &sym});
if (shard)
part.relrDyn->relocsVec[parallel::getThreadIndex()].push_back(
diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp
index 29928d1527484..c672429158792 100644
--- a/lld/ELF/ScriptParser.cpp
+++ b/lld/ELF/ScriptParser.cpp
@@ -1408,7 +1408,7 @@ Expr ScriptParser::readPrimary() {
OutputSection *osec = &script->getOrCreateOutputSection(name)->osec;
return [=] {
checkIfExists(*osec, location);
- return osec->alignment;
+ return osec->addralign;
};
}
if (tok == "ASSERT")
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index e80d05cbd51ec..24a6f40dbb934 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -890,7 +890,7 @@ void MipsGotSection::build() {
for (SectionCommand *cmd : os->commands) {
if (auto *isd = dyn_cast<InputSectionDescription>(cmd))
for (InputSection *isec : isd->sections) {
- uint64_t off = alignToPowerOf2(secSize, isec->alignment);
+ uint64_t off = alignToPowerOf2(secSize, isec->addralign);
secSize = off + isec->getSize();
}
}
@@ -2203,7 +2203,7 @@ template <class ELFT> void SymbolTableSection<ELFT>::writeTo(uint8_t *buf) {
// When -r is specified, a COMMON symbol is not allocated. Its st_shndx
// holds SHN_COMMON and st_value holds the alignment.
eSym->st_shndx = SHN_COMMON;
- eSym->st_value = commonSec->alignment;
+ eSym->st_value = commonSec->addralign;
eSym->st_size = cast<Defined>(sym)->size;
} else {
const uint32_t shndx = getSymSectionIndex(sym);
@@ -2484,7 +2484,7 @@ PltSection::PltSection()
// On PowerPC, this section contains lazy symbol resolvers.
if (config->emachine == EM_PPC64) {
name = ".glink";
- alignment = 4;
+ addralign = 4;
}
// On x86 when IBT is enabled, this section contains the second PLT (lazy
@@ -2542,7 +2542,7 @@ IpltSection::IpltSection()
: SyntheticSection(SHF_ALLOC | SHF_EXECINSTR, SHT_PROGBITS, 16, ".iplt") {
if (config->emachine == EM_PPC || config->emachine == EM_PPC64) {
name = ".glink";
- alignment = 4;
+ addralign = 4;
}
}
@@ -2575,7 +2575,7 @@ void IpltSection::addSymbols() {
PPC32GlinkSection::PPC32GlinkSection() {
name = ".glink";
- alignment = 4;
+ addralign = 4;
}
void PPC32GlinkSection::writeTo(uint8_t *buf) {
@@ -3203,8 +3203,8 @@ template <class ELFT> bool VersionNeedSection<ELFT>::isNeeded() const {
void MergeSyntheticSection::addSection(MergeInputSection *ms) {
ms->parent = this;
sections.push_back(ms);
- assert(alignment == ms->alignment || !(ms->flags & SHF_STRINGS));
- alignment = std::max(alignment, ms->alignment);
+ assert(addralign == ms->addralign || !(ms->flags & SHF_STRINGS));
+ addralign = std::max(addralign, ms->addralign);
}
MergeTailSection::MergeTailSection(StringRef name, uint32_t type,
@@ -3252,7 +3252,7 @@ void MergeNoTailSection::writeTo(uint8_t *buf) {
void MergeNoTailSection::finalizeContents() {
// Initializes string table builders.
for (size_t i = 0; i < numShards; ++i)
- shards.emplace_back(StringTableBuilder::RAW, alignment);
+ shards.emplace_back(StringTableBuilder::RAW, addralign);
// Concurrency level. Must be a power of 2 to avoid expensive modulo
// operations in the following tight loop.
@@ -3277,7 +3277,7 @@ void MergeNoTailSection::finalizeContents() {
for (size_t i = 0; i < numShards; ++i) {
shards[i].finalizeInOrder();
if (shards[i].getSize() > 0)
- off = alignToPowerOf2(off, alignment);
+ off = alignToPowerOf2(off, addralign);
shardOffsets[i] = off;
off += shards[i].getSize();
}
@@ -3314,7 +3314,7 @@ void elf::combineEhSections() {
for (EhInputSection *sec : ctx.ehInputSections) {
EhFrameSection &eh = *sec->getPartition().ehFrame;
sec->parent = &eh;
- eh.alignment = std::max(eh.alignment, sec->alignment);
+ eh.addralign = std::max(eh.addralign, sec->addralign);
eh.sections.push_back(sec);
llvm::append_range(eh.dependentSections, sec->dependentSections);
}
diff --git a/lld/ELF/SyntheticSections.h b/lld/ELF/SyntheticSections.h
index 0df9d6e241c41..9a3adfd5d3c74 100644
--- a/lld/ELF/SyntheticSections.h
+++ b/lld/ELF/SyntheticSections.h
@@ -164,7 +164,7 @@ class BuildIdSection : public SyntheticSection {
// respectively.
class BssSection final : public SyntheticSection {
public:
- BssSection(StringRef name, uint64_t size, uint32_t alignment);
+ BssSection(StringRef name, uint64_t size, uint32_t addralign);
void writeTo(uint8_t *) override {}
bool isNeeded() const override { return size != 0; }
size_t getSize() const override { return size; }
@@ -935,14 +935,14 @@ class MergeSyntheticSection : public SyntheticSection {
protected:
MergeSyntheticSection(StringRef name, uint32_t type, uint64_t flags,
- uint32_t alignment)
- : SyntheticSection(flags, type, alignment, name) {}
+ uint32_t addralign)
+ : SyntheticSection(flags, type, addralign, name) {}
};
class MergeTailSection final : public MergeSyntheticSection {
public:
MergeTailSection(StringRef name, uint32_t type, uint64_t flags,
- uint32_t alignment);
+ uint32_t addralign);
size_t getSize() const override;
void writeTo(uint8_t *buf) override;
@@ -955,8 +955,8 @@ class MergeTailSection final : public MergeSyntheticSection {
class MergeNoTailSection final : public MergeSyntheticSection {
public:
MergeNoTailSection(StringRef name, uint32_t type, uint64_t flags,
- uint32_t alignment)
- : MergeSyntheticSection(name, type, flags, alignment) {}
+ uint32_t addralign)
+ : MergeSyntheticSection(name, type, flags, addralign) {}
size_t getSize() const override { return size; }
void writeTo(uint8_t *buf) override;
diff --git a/lld/ELF/Writer.cpp b/lld/ELF/Writer.cpp
index ae2b7ffe4f973..6f04b31c57233 100644
--- a/lld/ELF/Writer.cpp
+++ b/lld/ELF/Writer.cpp
@@ -282,7 +282,7 @@ template <class ELFT> void elf::createSyntheticSections() {
in.shStrTab = std::make_unique<StringTableSection>(".shstrtab", false);
Out::programHeaders = make<OutputSection>("", 0, SHF_ALLOC);
- Out::programHeaders->alignment = config->wordsize;
+ Out::programHeaders->addralign = config->wordsize;
if (config->strip != StripPolicy::All) {
in.strTab = std::make_unique<StringTableSection>(".strtab", false);
@@ -992,7 +992,7 @@ void PhdrEntry::add(OutputSection *sec) {
lastSec = sec;
if (!firstSec)
firstSec = sec;
- p_align = std::max(p_align, sec->alignment);
+ p_align = std::max(p_align, sec->addralign);
if (p_type == PT_LOAD)
sec->ptLoad = this;
}
@@ -1684,10 +1684,10 @@ template <class ELFT> void Writer<ELFT>::finalizeAddressDependentContent() {
for (SectionCommand *cmd : script->sectionCommands)
if (auto *osd = dyn_cast<OutputDesc>(cmd)) {
OutputSection *osec = &osd->osec;
- if (osec->addr % osec->alignment != 0)
+ if (osec->addr % osec->addralign != 0)
warn("address (0x" + Twine::utohexstr(osec->addr) + ") of section " +
osec->name + " is not a multiple of alignment (" +
- Twine(osec->alignment) + ")");
+ Twine(osec->addralign) + ")");
}
}
@@ -2402,7 +2402,7 @@ SmallVector<PhdrEntry *, 0> Writer<ELFT>::createPhdrs(Partition &part) {
if (sec->partition != partNo)
continue;
if (sec->type == SHT_NOTE && (sec->flags & SHF_ALLOC)) {
- if (!note || sec->lmaExpr || note->lastSec->alignment != sec->alignment)
+ if (!note || sec->lmaExpr || note->lastSec->addralign != sec->addralign)
note = addHdr(PT_NOTE, PF_R);
note->add(sec);
} else {
@@ -2436,7 +2436,7 @@ template <class ELFT> void Writer<ELFT>::fixSectionAlignments() {
OutputSection *cmd = p->firstSec;
if (!cmd)
return;
- cmd->alignExpr = [align = cmd->alignment]() { return align; };
+ cmd->alignExpr = [align = cmd->addralign]() { return align; };
if (!cmd->addrExpr) {
// Prefer advancing to align(dot, maxPageSize) + dot%maxPageSize to avoid
// padding in the file contents.
@@ -2513,7 +2513,7 @@ static uint64_t computeFileOffset(OutputSection *os, uint64_t off) {
// If the section is not in a PT_LOAD, we just have to align it.
if (!os->ptLoad)
- return alignToPowerOf2(off, os->alignment);
+ return alignToPowerOf2(off, os->addralign);
// If two sections share the same PT_LOAD the file offset is calculated
// using this formula: Off2 = Off1 + (VA2 - VA1).
@@ -2576,7 +2576,7 @@ template <class ELFT> void Writer<ELFT>::assignFileOffsets() {
}
for (OutputSection *osec : outputSections)
if (!(osec->flags & SHF_ALLOC)) {
- osec->offset = alignToPowerOf2(off, osec->alignment);
+ osec->offset = alignToPowerOf2(off, osec->addralign);
off = osec->offset + osec->size;
}
More information about the llvm-commits
mailing list