mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-08-07 12:28:24 +00:00
MC: Tweak section layout to not relying on accumulating address value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103648 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -396,10 +396,15 @@ void MCAssembler::LayoutSection(MCAsmLayout &Layout,
|
|||||||
// Set the aligned section address.
|
// Set the aligned section address.
|
||||||
Layout.setSectionAddress(&SD, StartAddress);
|
Layout.setSectionAddress(&SD, StartAddress);
|
||||||
|
|
||||||
uint64_t Address = StartAddress;
|
|
||||||
for (MCSectionData::iterator it = SD.begin(), ie = SD.end(); it != ie; ++it) {
|
for (MCSectionData::iterator it = SD.begin(), ie = SD.end(); it != ie; ++it) {
|
||||||
MCFragment &F = *it;
|
MCFragment &F = *it;
|
||||||
|
|
||||||
|
// Compute the fragment start address.
|
||||||
|
uint64_t Address = StartAddress;
|
||||||
|
if (MCFragment *Prev = F.getPrevNode())
|
||||||
|
Address = (Layout.getFragmentAddress(Prev) +
|
||||||
|
Layout.getFragmentEffectiveSize(Prev));
|
||||||
|
|
||||||
++stats::FragmentLayouts;
|
++stats::FragmentLayouts;
|
||||||
|
|
||||||
uint64_t FragmentOffset = Address - StartAddress;
|
uint64_t FragmentOffset = Address - StartAddress;
|
||||||
@@ -464,15 +469,16 @@ void MCAssembler::LayoutSection(MCAsmLayout &Layout,
|
|||||||
}
|
}
|
||||||
|
|
||||||
Layout.setFragmentEffectiveSize(&F, EffectiveSize);
|
Layout.setFragmentEffectiveSize(&F, EffectiveSize);
|
||||||
Address += EffectiveSize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the section sizes.
|
// Set the section sizes.
|
||||||
Layout.setSectionSize(&SD, Address - StartAddress);
|
uint64_t Size = 0;
|
||||||
if (IsVirtual)
|
if (!SD.getFragmentList().empty()) {
|
||||||
Layout.setSectionFileSize(&SD, 0);
|
MCFragment *F = &SD.getFragmentList().back();
|
||||||
else
|
Size = Layout.getFragmentOffset(F) + Layout.getFragmentEffectiveSize(F);
|
||||||
Layout.setSectionFileSize(&SD, Address - StartAddress);
|
}
|
||||||
|
Layout.setSectionSize(&SD, Size);
|
||||||
|
Layout.setSectionFileSize(&SD, IsVirtual ? 0 : Size);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// WriteFragmentData - Write the \arg F data to the output file.
|
/// WriteFragmentData - Write the \arg F data to the output file.
|
||||||
|
Reference in New Issue
Block a user