Stop forwarding (get|set)Aligment from MCSectionData to MCSection.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@237956 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2015-05-21 21:02:35 +00:00
parent f8330b43ee
commit 477acf64d0
11 changed files with 39 additions and 47 deletions

View File

@ -115,7 +115,7 @@ uint64_t MachObjectWriter::getPaddingSize(const MCSectionData *SD,
const MCSectionData &NextSD = *Layout.getSectionOrder()[Next];
if (NextSD.getSection().isVirtualSection())
return 0;
return OffsetToAlignment(EndAddr, NextSD.getAlignment());
return OffsetToAlignment(EndAddr, NextSD.getSection().getAlignment());
}
void MachObjectWriter::WriteHeader(unsigned NumLoadCommands,
@ -199,9 +199,10 @@ void MachObjectWriter::WriteSection(const MCAssembler &Asm,
uint64_t RelocationsStart,
unsigned NumRelocations) {
uint64_t SectionSize = Layout.getSectionAddressSize(&SD);
const MCSectionMachO &Section = cast<MCSectionMachO>(SD.getSection());
// The offset is unused for virtual sections.
if (SD.getSection().isVirtualSection()) {
if (Section.isVirtualSection()) {
assert(Layout.getSectionFileSize(&SD) == 0 && "Invalid file size!");
FileOffset = 0;
}
@ -212,7 +213,6 @@ void MachObjectWriter::WriteSection(const MCAssembler &Asm,
uint64_t Start = OS.tell();
(void) Start;
const MCSectionMachO &Section = cast<MCSectionMachO>(SD.getSection());
WriteBytes(Section.getSectionName(), 16);
WriteBytes(Section.getSegmentName(), 16);
if (is64Bit()) {
@ -228,8 +228,8 @@ void MachObjectWriter::WriteSection(const MCAssembler &Asm,
if (SD.hasInstructions())
Flags |= MachO::S_ATTR_SOME_INSTRUCTIONS;
assert(isPowerOf2_32(SD.getAlignment()) && "Invalid alignment!");
Write32(Log2_32(SD.getAlignment()));
assert(isPowerOf2_32(Section.getAlignment()) && "Invalid alignment!");
Write32(Log2_32(Section.getAlignment()));
Write32(NumRelocations ? RelocationsStart : 0);
Write32(NumRelocations);
Write32(Flags);
@ -645,7 +645,8 @@ void MachObjectWriter::computeSectionAddresses(const MCAssembler &Asm,
const SmallVectorImpl<MCSectionData*> &Order = Layout.getSectionOrder();
for (int i = 0, n = Order.size(); i != n ; ++i) {
const MCSectionData *SD = Order[i];
StartAddress = RoundUpToAlignment(StartAddress, SD->getAlignment());
StartAddress =
RoundUpToAlignment(StartAddress, SD->getSection().getAlignment());
SectionAddress[SD] = StartAddress;
StartAddress += Layout.getSectionAddressSize(SD);