Skip to content

Commit e73353c

Browse files
committed
MC: Create dummy fragments to avoid ever having empty sections, which simplifies layout.
llvm-svn: 103710
1 parent e8845ef commit e73353c

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

llvm/lib/MC/MCAssembler.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -116,10 +116,6 @@ void MCAsmLayout::setSectionAddress(MCSectionData *SD, uint64_t Value) {
116116
}
117117

118118
uint64_t MCAsmLayout::getSectionAddressSize(const MCSectionData *SD) const {
119-
// Empty sections have no size.
120-
if (SD->getFragmentList().empty())
121-
return 0;
122-
123119
// Otherwise, the size is the last fragment's end offset.
124120
const MCFragment &F = SD->getFragmentList().back();
125121
return getFragmentOffset(&F) + getFragmentEffectiveSize(&F);
@@ -135,10 +131,6 @@ uint64_t MCAsmLayout::getSectionFileSize(const MCSectionData *SD) const {
135131
}
136132

137133
uint64_t MCAsmLayout::getSectionSize(const MCSectionData *SD) const {
138-
// Empty sections have no size.
139-
if (SD->getFragmentList().empty())
140-
return 0;
141-
142134
// The logical size is the address space size minus any tail padding.
143135
uint64_t Size = getSectionAddressSize(SD);
144136
const MCAlignFragment *AF =
@@ -611,6 +603,15 @@ void MCAssembler::Finish() {
611603
unsigned SectionIndex = 0;
612604
unsigned FragmentIndex = 0;
613605
for (MCAssembler::iterator it = begin(), ie = end(); it != ie; ++it) {
606+
// Create dummy fragments to eliminate any empty sections, this simplifies
607+
// layout.
608+
if (it->getFragmentList().empty()) {
609+
unsigned ValueSize = 1;
610+
if (getBackend().isVirtualSection(it->getSection()))
611+
ValueSize = 1;
612+
new MCFillFragment(0, 1, 0, it);
613+
}
614+
614615
it->setOrdinal(SectionIndex++);
615616

616617
for (MCSectionData::iterator it2 = it->begin(),

0 commit comments

Comments
 (0)