|
@@ -241,7 +241,7 @@ static void transferSegmentAndSections(
|
|
// start address leave a sufficient gap to store the __DWARF
|
|
// start address leave a sufficient gap to store the __DWARF
|
|
// segment.
|
|
// segment.
|
|
uint64_t PrevEndAddress = EndAddress;
|
|
uint64_t PrevEndAddress = EndAddress;
|
|
- EndAddress = RoundUpToAlignment(EndAddress, 0x1000);
|
|
|
|
|
|
+ EndAddress = alignTo(EndAddress, 0x1000);
|
|
if (GapForDwarf == UINT64_MAX && Segment.vmaddr > EndAddress &&
|
|
if (GapForDwarf == UINT64_MAX && Segment.vmaddr > EndAddress &&
|
|
Segment.vmaddr - EndAddress >= DwarfSegmentSize)
|
|
Segment.vmaddr - EndAddress >= DwarfSegmentSize)
|
|
GapForDwarf = EndAddress;
|
|
GapForDwarf = EndAddress;
|
|
@@ -268,8 +268,8 @@ static void createDwarfSegment(uint64_t VMAddr, uint64_t FileOffset,
|
|
uint64_t FileSize, unsigned NumSections,
|
|
uint64_t FileSize, unsigned NumSections,
|
|
MCAsmLayout &Layout, MachObjectWriter &Writer) {
|
|
MCAsmLayout &Layout, MachObjectWriter &Writer) {
|
|
Writer.writeSegmentLoadCommand("__DWARF", NumSections, VMAddr,
|
|
Writer.writeSegmentLoadCommand("__DWARF", NumSections, VMAddr,
|
|
- RoundUpToAlignment(FileSize, 0x1000),
|
|
|
|
- FileOffset, FileSize, /* MaxProt */ 7,
|
|
|
|
|
|
+ alignTo(FileSize, 0x1000), FileOffset,
|
|
|
|
+ FileSize, /* MaxProt */ 7,
|
|
/* InitProt =*/3);
|
|
/* InitProt =*/3);
|
|
|
|
|
|
for (unsigned int i = 0, n = Layout.getSectionOrder().size(); i != n; ++i) {
|
|
for (unsigned int i = 0, n = Layout.getSectionOrder().size(); i != n; ++i) {
|
|
@@ -279,8 +279,8 @@ static void createDwarfSegment(uint64_t VMAddr, uint64_t FileOffset,
|
|
|
|
|
|
unsigned Align = Sec->getAlignment();
|
|
unsigned Align = Sec->getAlignment();
|
|
if (Align > 1) {
|
|
if (Align > 1) {
|
|
- VMAddr = RoundUpToAlignment(VMAddr, Align);
|
|
|
|
- FileOffset = RoundUpToAlignment(FileOffset, Align);
|
|
|
|
|
|
+ VMAddr = alignTo(VMAddr, Align);
|
|
|
|
+ FileOffset = alignTo(FileOffset, Align);
|
|
}
|
|
}
|
|
Writer.writeSection(Layout, *Sec, VMAddr, FileOffset, 0, 0, 0);
|
|
Writer.writeSection(Layout, *Sec, VMAddr, FileOffset, 0, 0, 0);
|
|
|
|
|
|
@@ -394,8 +394,7 @@ bool generateDsymCompanion(const DebugMap &DM, MCStreamer &MS,
|
|
continue;
|
|
continue;
|
|
|
|
|
|
if (uint64_t Size = Layout.getSectionFileSize(Sec)) {
|
|
if (uint64_t Size = Layout.getSectionFileSize(Sec)) {
|
|
- DwarfSegmentSize =
|
|
|
|
- RoundUpToAlignment(DwarfSegmentSize, Sec->getAlignment());
|
|
|
|
|
|
+ DwarfSegmentSize = alignTo(DwarfSegmentSize, Sec->getAlignment());
|
|
DwarfSegmentSize += Size;
|
|
DwarfSegmentSize += Size;
|
|
++NumDwarfSections;
|
|
++NumDwarfSections;
|
|
}
|
|
}
|
|
@@ -419,7 +418,7 @@ bool generateDsymCompanion(const DebugMap &DM, MCStreamer &MS,
|
|
|
|
|
|
uint64_t SymtabStart = LoadCommandSize;
|
|
uint64_t SymtabStart = LoadCommandSize;
|
|
SymtabStart += HeaderSize;
|
|
SymtabStart += HeaderSize;
|
|
- SymtabStart = RoundUpToAlignment(SymtabStart, 0x1000);
|
|
|
|
|
|
+ SymtabStart = alignTo(SymtabStart, 0x1000);
|
|
|
|
|
|
// We gathered all the information we need, start emitting the output file.
|
|
// We gathered all the information we need, start emitting the output file.
|
|
Writer.writeHeader(MachO::MH_DSYM, NumLoadCommands, LoadCommandSize, false);
|
|
Writer.writeHeader(MachO::MH_DSYM, NumLoadCommands, LoadCommandSize, false);
|
|
@@ -441,7 +440,7 @@ bool generateDsymCompanion(const DebugMap &DM, MCStreamer &MS,
|
|
NewStringsSize);
|
|
NewStringsSize);
|
|
|
|
|
|
uint64_t DwarfSegmentStart = StringStart + NewStringsSize;
|
|
uint64_t DwarfSegmentStart = StringStart + NewStringsSize;
|
|
- DwarfSegmentStart = RoundUpToAlignment(DwarfSegmentStart, 0x1000);
|
|
|
|
|
|
+ DwarfSegmentStart = alignTo(DwarfSegmentStart, 0x1000);
|
|
|
|
|
|
// Write the load commands for the segments and sections we 'import' from
|
|
// Write the load commands for the segments and sections we 'import' from
|
|
// the original binary.
|
|
// the original binary.
|
|
@@ -460,7 +459,7 @@ bool generateDsymCompanion(const DebugMap &DM, MCStreamer &MS,
|
|
DwarfSegmentSize, GapForDwarf, EndAddress);
|
|
DwarfSegmentSize, GapForDwarf, EndAddress);
|
|
}
|
|
}
|
|
|
|
|
|
- uint64_t DwarfVMAddr = RoundUpToAlignment(EndAddress, 0x1000);
|
|
|
|
|
|
+ uint64_t DwarfVMAddr = alignTo(EndAddress, 0x1000);
|
|
uint64_t DwarfVMMax = Is64Bit ? UINT64_MAX : UINT32_MAX;
|
|
uint64_t DwarfVMMax = Is64Bit ? UINT64_MAX : UINT32_MAX;
|
|
if (DwarfVMAddr + DwarfSegmentSize > DwarfVMMax ||
|
|
if (DwarfVMAddr + DwarfSegmentSize > DwarfVMMax ||
|
|
DwarfVMAddr + DwarfSegmentSize < DwarfVMAddr /* Overflow */) {
|
|
DwarfVMAddr + DwarfSegmentSize < DwarfVMAddr /* Overflow */) {
|
|
@@ -510,7 +509,7 @@ bool generateDsymCompanion(const DebugMap &DM, MCStreamer &MS,
|
|
continue;
|
|
continue;
|
|
|
|
|
|
uint64_t Pos = OutFile.tell();
|
|
uint64_t Pos = OutFile.tell();
|
|
- Writer.WriteZeros(RoundUpToAlignment(Pos, Sec.getAlignment()) - Pos);
|
|
|
|
|
|
+ Writer.WriteZeros(alignTo(Pos, Sec.getAlignment()) - Pos);
|
|
MCAsm.writeSectionData(&Sec, Layout);
|
|
MCAsm.writeSectionData(&Sec, Layout);
|
|
}
|
|
}
|
|
|
|
|