Skip to content

Commit 1490141

Browse files
authored
Move MCSection::LayoutOrder to MCSectionMachO
This variable is similar to `Ordinal` but only used for Mach-O to place zerofill sections ("virtual sections" in MC term) after non-zerofill ones. Follow-up to 7840c00. Pull Request: #97474
1 parent 9fa7f40 commit 1490141

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

llvm/include/llvm/MC/MCSection.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ class MCSection {
8686
Align Alignment;
8787
/// The section index in the assemblers section list.
8888
unsigned Ordinal = 0;
89-
/// The index of this section in the layout order.
90-
unsigned LayoutOrder = 0;
9189

9290
/// Keeping track of bundle-locked state.
9391
BundleLockStateType BundleLockState = NotBundleLocked;
@@ -167,9 +165,6 @@ class MCSection {
167165
unsigned getOrdinal() const { return Ordinal; }
168166
void setOrdinal(unsigned Value) { Ordinal = Value; }
169167

170-
unsigned getLayoutOrder() const { return LayoutOrder; }
171-
void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
172-
173168
BundleLockStateType getBundleLockState() const { return BundleLockState; }
174169
void setBundleLockState(BundleLockStateType NewState);
175170
bool isBundleLocked() const { return BundleLockState != NotBundleLocked; }

llvm/include/llvm/MC/MCSectionMachO.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ class MCSectionMachO final : public MCSection {
3232
/// for example.
3333
unsigned Reserved2;
3434

35+
// The index of this section in MachObjectWriter::SectionOrder, which is
36+
// different from MCSection::Ordinal.
37+
unsigned LayoutOrder = 0;
38+
3539
// The defining non-temporary symbol for each fragment.
3640
SmallVector<const MCSymbol *, 0> Atoms;
3741

@@ -80,6 +84,9 @@ class MCSectionMachO final : public MCSection {
8084
const MCSymbol *getAtom(size_t I) const;
8185
void setAtom(size_t I, const MCSymbol *Sym);
8286

87+
unsigned getLayoutOrder() const { return LayoutOrder; }
88+
void setLayoutOrder(unsigned Value) { LayoutOrder = Value; }
89+
8390
static bool classof(const MCSection *S) {
8491
return S->getVariant() == SV_MachO;
8592
}

llvm/lib/MC/MachObjectWriter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ uint64_t MachObjectWriter::getSymbolAddress(const MCSymbol &S,
125125
uint64_t MachObjectWriter::getPaddingSize(const MCAssembler &Asm,
126126
const MCSection *Sec) const {
127127
uint64_t EndAddr = getSectionAddress(Sec) + Asm.getSectionAddressSize(*Sec);
128-
unsigned Next = Sec->getLayoutOrder() + 1;
128+
unsigned Next = cast<MCSectionMachO>(Sec)->getLayoutOrder() + 1;
129129
if (Next >= SectionOrder.size())
130130
return 0;
131131

@@ -676,13 +676,13 @@ void MachObjectWriter::computeSectionAddresses(const MCAssembler &Asm) {
676676
for (MCSection &Sec : Asm) {
677677
if (!Sec.isVirtualSection()) {
678678
SectionOrder.push_back(&Sec);
679-
Sec.setLayoutOrder(i++);
679+
cast<MCSectionMachO>(Sec).setLayoutOrder(i++);
680680
}
681681
}
682682
for (MCSection &Sec : Asm) {
683683
if (Sec.isVirtualSection()) {
684684
SectionOrder.push_back(&Sec);
685-
Sec.setLayoutOrder(i++);
685+
cast<MCSectionMachO>(Sec).setLayoutOrder(i++);
686686
}
687687
}
688688

0 commit comments

Comments
 (0)