forked from OSchip/llvm-project
parent
791fd160c3
commit
489a806965
|
@ -310,7 +310,7 @@ void SEHTableChunk::writeTo(uint8_t *Buf) const {
|
|||
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(align((End - Begin) * 2 + 8, 4));
|
||||
Data.resize(alignTo((End - Begin) * 2 + 8, 4));
|
||||
uint8_t *P = Data.data();
|
||||
write32le(P, Page);
|
||||
write32le(P + 4, Data.size());
|
||||
|
|
|
@ -326,10 +326,6 @@ public:
|
|||
uint8_t Type;
|
||||
};
|
||||
|
||||
inline uint64_t align(uint64_t Value, uint64_t Align) {
|
||||
return llvm::RoundUpToAlignment(Value, Align);
|
||||
}
|
||||
|
||||
} // namespace coff
|
||||
} // namespace lld
|
||||
|
||||
|
|
|
@ -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 align(Name.size() + 3, 2);
|
||||
return alignTo(Name.size() + 3, 2);
|
||||
}
|
||||
|
||||
void writeTo(uint8_t *Buf) const override {
|
||||
|
|
|
@ -163,13 +163,13 @@ void OutputSection::addChunk(Chunk *C) {
|
|||
Chunks.push_back(C);
|
||||
C->setOutputSection(this);
|
||||
uint64_t Off = Header.VirtualSize;
|
||||
Off = align(Off, C->getAlign());
|
||||
Off = alignTo(Off, C->getAlign());
|
||||
C->setRVA(Off);
|
||||
C->setOutputSectionOff(Off);
|
||||
Off += C->getSize();
|
||||
Header.VirtualSize = Off;
|
||||
if (C->hasData())
|
||||
Header.SizeOfRawData = align(Off, SectorSize);
|
||||
Header.SizeOfRawData = alignTo(Off, SectorSize);
|
||||
}
|
||||
|
||||
void OutputSection::addPermissions(uint32_t C) {
|
||||
|
@ -447,15 +447,15 @@ 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() + align(LastSection->getRawSize(), SectorSize);
|
||||
uint64_t FileOff = LastSection->getFileOff() +
|
||||
alignTo(LastSection->getRawSize(), SectorSize);
|
||||
if (!OutputSymtab.empty()) {
|
||||
PointerToSymbolTable = FileOff;
|
||||
FileOff += OutputSymtab.size() * sizeof(coff_symbol16);
|
||||
}
|
||||
if (!Strtab.empty())
|
||||
FileOff += Strtab.size() + 4;
|
||||
FileSize = align(FileOff, SectorSize);
|
||||
FileSize = alignTo(FileOff, SectorSize);
|
||||
}
|
||||
|
||||
// Visits all sections to assign incremental, non-overlapping RVAs and
|
||||
|
@ -466,7 +466,7 @@ void Writer::assignAddresses() {
|
|||
sizeof(coff_section) * OutputSections.size();
|
||||
SizeOfHeaders +=
|
||||
Config->is64() ? sizeof(pe32plus_header) : sizeof(pe32_header);
|
||||
SizeOfHeaders = align(SizeOfHeaders, SectorSize);
|
||||
SizeOfHeaders = alignTo(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
|
||||
|
@ -480,10 +480,10 @@ void Writer::assignAddresses() {
|
|||
addBaserels(Sec);
|
||||
Sec->setRVA(RVA);
|
||||
Sec->setFileOffset(FileSize);
|
||||
RVA += align(Sec->getVirtualSize(), PageSize);
|
||||
FileSize += align(Sec->getRawSize(), SectorSize);
|
||||
RVA += alignTo(Sec->getVirtualSize(), PageSize);
|
||||
FileSize += alignTo(Sec->getRawSize(), SectorSize);
|
||||
}
|
||||
SizeOfImage = SizeOfHeaders + align(RVA - 0x1000, PageSize);
|
||||
SizeOfImage = SizeOfHeaders + alignTo(RVA - 0x1000, PageSize);
|
||||
}
|
||||
|
||||
template <typename PEHeaderTy> void Writer::writeHeader() {
|
||||
|
|
|
@ -770,7 +770,7 @@ void OutputSection<ELFT>::addSection(InputSectionBase<ELFT> *C) {
|
|||
this->Header.sh_addralign = Align;
|
||||
|
||||
uintX_t Off = this->Header.sh_size;
|
||||
Off = align(Off, Align);
|
||||
Off = alignTo(Off, Align);
|
||||
S->OutSecOff = Off;
|
||||
Off += S->getSize();
|
||||
this->Header.sh_size = Off;
|
||||
|
@ -976,7 +976,7 @@ void EHOutputSection<ELFT>::addSectionAux(
|
|||
auto P = CieMap.insert(std::make_pair(CieInfo, Cies.size()));
|
||||
if (P.second) {
|
||||
Cies.push_back(C);
|
||||
this->Header.sh_size += align(Length, sizeof(uintX_t));
|
||||
this->Header.sh_size += alignTo(Length, sizeof(uintX_t));
|
||||
}
|
||||
OffsetToIndex[Offset] = P.first->second;
|
||||
} else {
|
||||
|
@ -989,7 +989,7 @@ void EHOutputSection<ELFT>::addSectionAux(
|
|||
if (I == OffsetToIndex.end())
|
||||
error("Invalid CIE reference");
|
||||
Cies[I->second].Fdes.push_back(EHRegion<ELFT>(S, Index));
|
||||
this->Header.sh_size += align(Length, sizeof(uintX_t));
|
||||
this->Header.sh_size += alignTo(Length, sizeof(uintX_t));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1042,7 +1042,7 @@ static typename ELFFile<ELFT>::uintX_t writeAlignedCieOrFde(StringRef Data,
|
|||
uint8_t *Buf) {
|
||||
typedef typename ELFFile<ELFT>::uintX_t uintX_t;
|
||||
const endianness E = ELFT::TargetEndianness;
|
||||
uint64_t Len = align(Data.size(), sizeof(uintX_t));
|
||||
uint64_t Len = alignTo(Data.size(), sizeof(uintX_t));
|
||||
write32<E>(Buf, Len - 4);
|
||||
memcpy(Buf + 4, Data.data() + 4, Data.size() - 4);
|
||||
return Len;
|
||||
|
|
|
@ -429,10 +429,6 @@ private:
|
|||
uint32_t GprMask = 0;
|
||||
};
|
||||
|
||||
inline uint64_t align(uint64_t Value, uint64_t Align) {
|
||||
return llvm::RoundUpToAlignment(Value, Align);
|
||||
}
|
||||
|
||||
// All output sections that are hadnled by the linker specially are
|
||||
// globally accessible. Writer initializes them, so don't use them
|
||||
// until Writer is initialized.
|
||||
|
|
|
@ -504,7 +504,7 @@ void Writer<ELFT>::addCommonSymbols(std::vector<DefinedCommon *> &Syms) {
|
|||
|
||||
uintX_t Off = getBss()->getSize();
|
||||
for (DefinedCommon *C : Syms) {
|
||||
Off = align(Off, C->MaxAlignment);
|
||||
Off = alignTo(Off, C->MaxAlignment);
|
||||
C->OffsetInBss = Off;
|
||||
Off += C->Size;
|
||||
}
|
||||
|
@ -527,7 +527,7 @@ void Writer<ELFT>::addCopyRelSymbols(std::vector<SharedSymbol<ELFT> *> &Syms) {
|
|||
countTrailingZeros((uintX_t)Sym.st_value));
|
||||
uintX_t Align = 1 << TrailingZeros;
|
||||
Out<ELFT>::Bss->updateAlign(Align);
|
||||
Off = align(Off, Align);
|
||||
Off = alignTo(Off, Align);
|
||||
C->OffsetInBss = Off;
|
||||
Off += Sym.st_size;
|
||||
}
|
||||
|
@ -1045,8 +1045,8 @@ template <class ELFT> void Writer<ELFT>::assignAddresses() {
|
|||
bool InRelRo = Config->ZRelro && (Flags & PF_W) && isRelroSection(Sec);
|
||||
bool FirstNonRelRo = GnuRelroPhdr.p_type && !InRelRo && !RelroAligned;
|
||||
if (FirstNonRelRo || PH->p_flags != Flags) {
|
||||
VA = align(VA, Target->getPageSize());
|
||||
FileOff = align(FileOff, Target->getPageSize());
|
||||
VA = alignTo(VA, Target->getPageSize());
|
||||
FileOff = alignTo(FileOff, Target->getPageSize());
|
||||
if (FirstNonRelRo)
|
||||
RelroAligned = true;
|
||||
}
|
||||
|
@ -1063,8 +1063,8 @@ template <class ELFT> void Writer<ELFT>::assignAddresses() {
|
|||
if (!TlsPhdr.p_vaddr)
|
||||
setPhdr(&TlsPhdr, PT_TLS, PF_R, FileOff, VA, 0, Sec->getAlign());
|
||||
if (Sec->getType() != SHT_NOBITS)
|
||||
VA = align(VA, Sec->getAlign());
|
||||
uintX_t TVA = align(VA + ThreadBssOffset, Sec->getAlign());
|
||||
VA = alignTo(VA, Sec->getAlign());
|
||||
uintX_t TVA = alignTo(VA + ThreadBssOffset, Sec->getAlign());
|
||||
Sec->setVA(TVA);
|
||||
TlsPhdr.p_memsz += Sec->getSize();
|
||||
if (Sec->getType() == SHT_NOBITS) {
|
||||
|
@ -1075,7 +1075,7 @@ template <class ELFT> void Writer<ELFT>::assignAddresses() {
|
|||
}
|
||||
TlsPhdr.p_align = std::max<uintX_t>(TlsPhdr.p_align, Sec->getAlign());
|
||||
} else {
|
||||
VA = align(VA, Sec->getAlign());
|
||||
VA = alignTo(VA, Sec->getAlign());
|
||||
Sec->setVA(VA);
|
||||
VA += Sec->getSize();
|
||||
if (InRelRo)
|
||||
|
@ -1083,7 +1083,7 @@ template <class ELFT> void Writer<ELFT>::assignAddresses() {
|
|||
}
|
||||
}
|
||||
|
||||
FileOff = align(FileOff, Sec->getAlign());
|
||||
FileOff = alignTo(FileOff, Sec->getAlign());
|
||||
Sec->setFileOffset(FileOff);
|
||||
if (Sec->getType() != SHT_NOBITS)
|
||||
FileOff += Sec->getSize();
|
||||
|
@ -1096,7 +1096,7 @@ template <class ELFT> void Writer<ELFT>::assignAddresses() {
|
|||
if (TlsPhdr.p_vaddr) {
|
||||
// The TLS pointer goes after PT_TLS. At least glibc will align it,
|
||||
// so round up the size to make sure the offsets are correct.
|
||||
TlsPhdr.p_memsz = align(TlsPhdr.p_memsz, TlsPhdr.p_align);
|
||||
TlsPhdr.p_memsz = alignTo(TlsPhdr.p_memsz, TlsPhdr.p_align);
|
||||
Phdrs[++PhdrIdx] = TlsPhdr;
|
||||
Out<ELFT>::TlsPhdr = &Phdrs[PhdrIdx];
|
||||
}
|
||||
|
@ -1128,7 +1128,7 @@ template <class ELFT> void Writer<ELFT>::assignAddresses() {
|
|||
}
|
||||
|
||||
// Add space for section headers.
|
||||
SectionHeaderOff = align(FileOff, ELFT::Is64Bits ? 8 : 4);
|
||||
SectionHeaderOff = alignTo(FileOff, ELFT::Is64Bits ? 8 : 4);
|
||||
FileSize = SectionHeaderOff + getNumSections() * sizeof(Elf_Shdr);
|
||||
|
||||
// Update "_end" and "end" symbols so that they
|
||||
|
|
|
@ -40,7 +40,7 @@ public:
|
|||
std::call_once(_tpOffOnce, [this]() {
|
||||
for (const auto &phdr : *_programHeader) {
|
||||
if (phdr->p_type == llvm::ELF::PT_TLS) {
|
||||
_tpOff = llvm::RoundUpToAlignment(TCB_SIZE, phdr->p_align);
|
||||
_tpOff = llvm::alignTo(TCB_SIZE, phdr->p_align);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,7 +122,7 @@ public:
|
|||
std::call_once(_tpOffOnce, [this]() {
|
||||
for (const auto &phdr : *_programHeader) {
|
||||
if (phdr->p_type == llvm::ELF::PT_TLS) {
|
||||
_tpOff = llvm::RoundUpToAlignment(TCB_SIZE, phdr->p_align);
|
||||
_tpOff = llvm::alignTo(TCB_SIZE, phdr->p_align);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ MipsOptionsSection<ELFT>::MipsOptionsSection(
|
|||
this->setOrder(MipsTargetLayout<ELFT>::ORDER_MIPS_OPTIONS);
|
||||
this->_entSize = 1;
|
||||
this->_alignment = 8;
|
||||
this->_fsize = llvm::RoundUpToAlignment(
|
||||
this->_fsize = llvm::alignTo(
|
||||
sizeof(Elf_Mips_Options) + sizeof(Elf_Mips_RegInfo), this->_alignment);
|
||||
this->_msize = this->_fsize;
|
||||
this->_type = SHT_MIPS_OPTIONS;
|
||||
|
@ -100,7 +100,7 @@ MipsAbiFlagsSection<ELFT>::MipsAbiFlagsSection(
|
|||
_targetLayout(targetLayout) {
|
||||
this->setOrder(MipsTargetLayout<ELFT>::ORDER_MIPS_ABI_FLAGS);
|
||||
this->_alignment = 8;
|
||||
this->_fsize = llvm::RoundUpToAlignment(sizeof(_abiFlags), this->_alignment);
|
||||
this->_fsize = llvm::alignTo(sizeof(_abiFlags), this->_alignment);
|
||||
this->_msize = this->_fsize;
|
||||
this->_entSize = this->_fsize;
|
||||
this->_type = SHT_MIPS_ABIFLAGS;
|
||||
|
|
|
@ -156,7 +156,7 @@ void Segment<ELFT>::assignFileOffsets(uint64_t startOffset) {
|
|||
fileOffset = newOffset;
|
||||
}
|
||||
// Align fileoffset to the alignment of the section.
|
||||
fileOffset = llvm::RoundUpToAlignment(fileOffset, section->alignment());
|
||||
fileOffset = llvm::alignTo(fileOffset, section->alignment());
|
||||
// If the linker outputmagic is set to OutputMagic::NMAGIC, align the Data
|
||||
// to a page boundary
|
||||
if (isFirstSection &&
|
||||
|
@ -165,18 +165,17 @@ void Segment<ELFT>::assignFileOffsets(uint64_t startOffset) {
|
|||
// Align to a page only if the output is not
|
||||
// OutputMagic::NMAGIC/OutputMagic::OMAGIC
|
||||
if (alignSegments)
|
||||
fileOffset = llvm::RoundUpToAlignment(fileOffset, p_align);
|
||||
fileOffset = llvm::alignTo(fileOffset, p_align);
|
||||
// Align according to ELF spec.
|
||||
// in p75, http://www.sco.com/developers/devspecs/gabi41.pdf
|
||||
uint64_t virtualAddress = slice->virtualAddr();
|
||||
Section<ELFT> *sect = dyn_cast<Section<ELFT>>(section);
|
||||
if (sect && sect->isLoadableSection() &&
|
||||
((virtualAddress & (p_align - 1)) != (fileOffset & (p_align - 1))))
|
||||
fileOffset = llvm::RoundUpToAlignment(fileOffset, p_align) +
|
||||
(virtualAddress % p_align);
|
||||
fileOffset =
|
||||
llvm::alignTo(fileOffset, p_align) + (virtualAddress % p_align);
|
||||
} else if (!isDataPageAlignedForNMagic && needAlign(section)) {
|
||||
fileOffset =
|
||||
llvm::RoundUpToAlignment(fileOffset, this->_ctx.getPageSize());
|
||||
fileOffset = llvm::alignTo(fileOffset, this->_ctx.getPageSize());
|
||||
isDataPageAlignedForNMagic = true;
|
||||
}
|
||||
if (isFirstSection) {
|
||||
|
@ -228,15 +227,15 @@ template <class ELFT> void Segment<ELFT>::assignVirtualAddress(uint64_t addr) {
|
|||
_outputMagic != ELFLinkingContext::OutputMagic::OMAGIC) {
|
||||
// Align to a page only if the output is not
|
||||
// OutputMagic::NMAGIC/OutputMagic::OMAGIC
|
||||
startAddr = llvm::RoundUpToAlignment(startAddr, this->_ctx.getPageSize());
|
||||
startAddr = llvm::alignTo(startAddr, this->_ctx.getPageSize());
|
||||
} else if (needAlign(*si)) {
|
||||
// If the linker outputmagic is set to OutputMagic::NMAGIC, align the
|
||||
// Data to a page boundary.
|
||||
startAddr = llvm::RoundUpToAlignment(startAddr, this->_ctx.getPageSize());
|
||||
startAddr = llvm::alignTo(startAddr, this->_ctx.getPageSize());
|
||||
isDataPageAlignedForNMagic = true;
|
||||
}
|
||||
// align the startOffset to the section alignment
|
||||
uint64_t newAddr = llvm::RoundUpToAlignment(startAddr, (*si)->alignment());
|
||||
uint64_t newAddr = llvm::alignTo(startAddr, (*si)->alignment());
|
||||
// Handle linker script expressions, which *may update newAddr* if the
|
||||
// expression assigns to "."
|
||||
if (auto expr = dyn_cast<ExpressionChunk<ELFT>>(*si))
|
||||
|
@ -248,8 +247,7 @@ template <class ELFT> void Segment<ELFT>::assignVirtualAddress(uint64_t addr) {
|
|||
// Handle TLS.
|
||||
if (auto section = dyn_cast<Section<ELFT>>(*si)) {
|
||||
if (section->getSegmentType() == llvm::ELF::PT_TLS) {
|
||||
tlsStartAddr =
|
||||
llvm::RoundUpToAlignment(tlsStartAddr, (*si)->alignment());
|
||||
tlsStartAddr = llvm::alignTo(tlsStartAddr, (*si)->alignment());
|
||||
section->assignVirtualAddress(tlsStartAddr);
|
||||
tlsStartAddr += (*si)->memSize();
|
||||
} else {
|
||||
|
@ -278,11 +276,11 @@ template <class ELFT> void Segment<ELFT>::assignVirtualAddress(uint64_t addr) {
|
|||
// If the linker outputmagic is set to OutputMagic::NMAGIC, align the
|
||||
// Data
|
||||
// to a page boundary
|
||||
curAddr = llvm::RoundUpToAlignment(curAddr, this->_ctx.getPageSize());
|
||||
curAddr = llvm::alignTo(curAddr, this->_ctx.getPageSize());
|
||||
isDataPageAlignedForNMagic = true;
|
||||
}
|
||||
uint64_t newAddr = llvm::RoundUpToAlignment(
|
||||
forceScriptAddr ? scriptAddr : curAddr, (*si)->alignment());
|
||||
uint64_t newAddr = llvm::alignTo(forceScriptAddr ? scriptAddr : curAddr,
|
||||
(*si)->alignment());
|
||||
forceScriptAddr = false;
|
||||
|
||||
// Handle linker script expressions, which may force an address change if
|
||||
|
@ -347,8 +345,7 @@ template <class ELFT> void Segment<ELFT>::assignVirtualAddress(uint64_t addr) {
|
|||
// Handle TLS.
|
||||
if (auto section = dyn_cast<Section<ELFT>>(*si)) {
|
||||
if (section->getSegmentType() == llvm::ELF::PT_TLS) {
|
||||
tlsStartAddr =
|
||||
llvm::RoundUpToAlignment(tlsStartAddr, (*si)->alignment());
|
||||
tlsStartAddr = llvm::alignTo(tlsStartAddr, (*si)->alignment());
|
||||
section->assignVirtualAddress(tlsStartAddr);
|
||||
tlsStartAddr += (*si)->memSize();
|
||||
} else {
|
||||
|
|
|
@ -616,7 +616,7 @@ void TargetLayout<ELFT>::assignFileOffsetsForMiscSections() {
|
|||
section = dyn_cast<Section<ELFT>>(si);
|
||||
if (section && TargetLayout<ELFT>::hasOutputSegment(section))
|
||||
continue;
|
||||
fileoffset = llvm::RoundUpToAlignment(fileoffset, si->alignment());
|
||||
fileoffset = llvm::alignTo(fileoffset, si->alignment());
|
||||
si->setFileOffset(fileoffset);
|
||||
si->setVirtualAddr(0);
|
||||
fileoffset += si->fileSize();
|
||||
|
|
|
@ -255,7 +255,7 @@ StringRef MachOFileLayout::dyldPath() {
|
|||
}
|
||||
|
||||
uint32_t MachOFileLayout::pointerAlign(uint32_t value) {
|
||||
return llvm::RoundUpToAlignment(value, _is64 ? 8 : 4);
|
||||
return llvm::alignTo(value, _is64 ? 8 : 4);
|
||||
}
|
||||
|
||||
|
||||
|
@ -292,7 +292,7 @@ MachOFileLayout::MachOFileLayout(const NormalizedFile &file)
|
|||
if (isZeroFillSection(sect.type))
|
||||
_sectInfo[§].fileOffset = 0;
|
||||
else {
|
||||
offset = llvm::RoundUpToAlignment(offset, sect.alignment);
|
||||
offset = llvm::alignTo(offset, sect.alignment);
|
||||
_sectInfo[§].fileOffset = offset;
|
||||
offset += sect.content.size();
|
||||
}
|
||||
|
@ -539,10 +539,8 @@ void MachOFileLayout::buildFileOffsets() {
|
|||
<< ", fileOffset=" << fileOffset << "\n");
|
||||
}
|
||||
|
||||
_segInfo[&sg].fileSize = llvm::RoundUpToAlignment(segFileSize,
|
||||
_file.pageSize);
|
||||
fileOffset = llvm::RoundUpToAlignment(fileOffset + segFileSize,
|
||||
_file.pageSize);
|
||||
_segInfo[&sg].fileSize = llvm::alignTo(segFileSize, _file.pageSize);
|
||||
fileOffset = llvm::alignTo(fileOffset + segFileSize, _file.pageSize);
|
||||
_addressOfLinkEdit = sg.address + sg.size;
|
||||
}
|
||||
_startOfLinkEdit = fileOffset;
|
||||
|
@ -679,7 +677,7 @@ std::error_code MachOFileLayout::writeSegmentLoadCommands(uint8_t *&lc) {
|
|||
uint8_t *next = lc + cmd->cmdsize;
|
||||
setString16("__LINKEDIT", cmd->segname);
|
||||
cmd->vmaddr = _addressOfLinkEdit;
|
||||
cmd->vmsize = llvm::RoundUpToAlignment(linkeditSize, _file.pageSize);
|
||||
cmd->vmsize = llvm::alignTo(linkeditSize, _file.pageSize);
|
||||
cmd->fileoff = _startOfLinkEdit;
|
||||
cmd->filesize = linkeditSize;
|
||||
cmd->maxprot = VM_PROT_READ;
|
||||
|
|
|
@ -465,10 +465,10 @@ void Util::organizeSections() {
|
|||
void Util::layoutSectionsInSegment(SegmentInfo *seg, uint64_t &addr) {
|
||||
seg->address = addr;
|
||||
for (SectionInfo *sect : seg->sections) {
|
||||
sect->address = llvm::RoundUpToAlignment(addr, sect->alignment);
|
||||
sect->address = llvm::alignTo(addr, sect->alignment);
|
||||
addr = sect->address + sect->size;
|
||||
}
|
||||
seg->size = llvm::RoundUpToAlignment(addr - seg->address, _ctx.pageSize());
|
||||
seg->size = llvm::alignTo(addr - seg->address, _ctx.pageSize());
|
||||
}
|
||||
|
||||
// __TEXT segment lays out backwards so padding is at front after load commands.
|
||||
|
@ -488,10 +488,10 @@ void Util::layoutSectionsInTextSegment(size_t hlcSize, SegmentInfo *seg,
|
|||
// Start assigning section address starting at padded offset.
|
||||
addr += (padding + hlcSize);
|
||||
for (SectionInfo *sect : seg->sections) {
|
||||
sect->address = llvm::RoundUpToAlignment(addr, sect->alignment);
|
||||
sect->address = llvm::alignTo(addr, sect->alignment);
|
||||
addr = sect->address + sect->size;
|
||||
}
|
||||
seg->size = llvm::RoundUpToAlignment(addr - seg->address, _ctx.pageSize());
|
||||
seg->size = llvm::alignTo(addr - seg->address, _ctx.pageSize());
|
||||
}
|
||||
|
||||
void Util::assignAddressesToSections(const NormalizedFile &file) {
|
||||
|
@ -511,7 +511,7 @@ void Util::assignAddressesToSections(const NormalizedFile &file) {
|
|||
} else
|
||||
layoutSectionsInSegment(seg, address);
|
||||
|
||||
address = llvm::RoundUpToAlignment(address, _ctx.pageSize());
|
||||
address = llvm::alignTo(address, _ctx.pageSize());
|
||||
}
|
||||
DEBUG_WITH_TYPE("WriterMachO-norm",
|
||||
llvm::dbgs() << "assignAddressesToSections()\n";
|
||||
|
|
Loading…
Reference in New Issue