Skip to content

Commit 6b707a8

Browse files
committed
[MC] Remove the MCAsmLayout parameter from MCObjectWriter::executePostLayoutBinding
1 parent 75ec24e commit 6b707a8

11 files changed

+24
-44
lines changed

llvm/include/llvm/MC/MCMachObjectWriter.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,11 +249,9 @@ class MachObjectWriter : public MCObjectWriter {
249249
std::vector<MachSymbolData> &ExternalSymbolData,
250250
std::vector<MachSymbolData> &UndefinedSymbolData);
251251

252-
void computeSectionAddresses(const MCAssembler &Asm,
253-
const MCAsmLayout &Layout);
252+
void computeSectionAddresses(const MCAssembler &Asm);
254253

255-
void executePostLayoutBinding(MCAssembler &Asm,
256-
const MCAsmLayout &Layout) override;
254+
void executePostLayoutBinding(MCAssembler &Asm) override;
257255

258256
bool isSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
259257
const MCSymbol &SymA,

llvm/include/llvm/MC/MCObjectWriter.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,7 @@ class MCObjectWriter {
5454
///
5555
/// This routine is called by the assembler after layout and relaxation is
5656
/// complete.
57-
virtual void executePostLayoutBinding(MCAssembler &Asm,
58-
const MCAsmLayout &Layout) = 0;
57+
virtual void executePostLayoutBinding(MCAssembler &Asm) {}
5958

6059
/// Record a relocation entry.
6160
///

llvm/lib/MC/ELFObjectWriter.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,7 @@ class ELFObjectWriter : public MCObjectWriter {
259259
uint64_t &FixedValue) override;
260260
bool usesRela(const MCTargetOptions *TO, const MCSectionELF &Sec) const;
261261

262-
void executePostLayoutBinding(MCAssembler &Asm,
263-
const MCAsmLayout &Layout) override;
262+
void executePostLayoutBinding(MCAssembler &Asm) override;
264263

265264
void markGnuAbi() override { SeenGnuAbi = true; }
266265
bool seenGnuAbi() const { return SeenGnuAbi; }
@@ -1274,8 +1273,7 @@ bool ELFObjectWriter::hasRelocationAddend() const {
12741273
return TargetObjectWriter->hasRelocationAddend();
12751274
}
12761275

1277-
void ELFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
1278-
const MCAsmLayout &Layout) {
1276+
void ELFObjectWriter::executePostLayoutBinding(MCAssembler &Asm) {
12791277
// The presence of symbol versions causes undefined symbols and
12801278
// versions declared with @@@ to be renamed.
12811279
for (const MCAssembler::Symver &S : Asm.Symvers) {

llvm/lib/MC/GOFFObjectWriter.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,6 @@ class GOFFObjectWriter : public MCObjectWriter {
239239
void recordRelocation(MCAssembler &Asm, const MCFragment *Fragment,
240240
const MCFixup &Fixup, MCValue Target,
241241
uint64_t &FixedValue) override {}
242-
void executePostLayoutBinding(MCAssembler &Asm,
243-
const MCAsmLayout &Layout) override {}
244242
uint64_t writeObject(MCAssembler &Asm) override;
245243
};
246244
} // end anonymous namespace

llvm/lib/MC/MCAssembler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ void MCAssembler::layout(MCAsmLayout &Layout) {
10221022

10231023
// Allow the object writer a chance to perform post-layout binding (for
10241024
// example, to set the index fields in the symbol data).
1025-
getWriter().executePostLayoutBinding(*this, Layout);
1025+
getWriter().executePostLayoutBinding(*this);
10261026

10271027
// Evaluate and apply the fixups, generating relocation entries as necessary.
10281028
for (MCSection &Sec : *this) {

llvm/lib/MC/MCDXContainerWriter.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@ class DXContainerObjectWriter : public MCObjectWriter {
3939
const MCFixup &Fixup, MCValue Target,
4040
uint64_t &FixedValue) override {}
4141

42-
void executePostLayoutBinding(MCAssembler &Asm,
43-
const MCAsmLayout &Layout) override {}
44-
4542
uint64_t writeObject(MCAssembler &Asm) override;
4643
};
4744
} // namespace

llvm/lib/MC/MachObjectWriter.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -668,24 +668,22 @@ void MachObjectWriter::computeSymbolTable(
668668
}
669669
}
670670

671-
void MachObjectWriter::computeSectionAddresses(const MCAssembler &Asm,
672-
const MCAsmLayout &Layout) {
671+
void MachObjectWriter::computeSectionAddresses(const MCAssembler &Asm) {
673672
uint64_t StartAddress = 0;
674-
for (const MCSection *Sec : Layout.getSectionOrder()) {
673+
for (const MCSection *Sec : Asm.getLayout()->getSectionOrder()) {
675674
StartAddress = alignTo(StartAddress, Sec->getAlign());
676675
SectionAddress[Sec] = StartAddress;
677-
StartAddress += Layout.getSectionAddressSize(Sec);
676+
StartAddress += Asm.getSectionAddressSize(*Sec);
678677

679678
// Explicitly pad the section to match the alignment requirements of the
680679
// following one. This is for 'gas' compatibility, it shouldn't
681680
/// strictly be necessary.
682-
StartAddress += getPaddingSize(Sec, Layout);
681+
StartAddress += getPaddingSize(Sec, *Asm.getLayout());
683682
}
684683
}
685684

686-
void MachObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
687-
const MCAsmLayout &Layout) {
688-
computeSectionAddresses(Asm, Layout);
685+
void MachObjectWriter::executePostLayoutBinding(MCAssembler &Asm) {
686+
computeSectionAddresses(Asm);
689687

690688
// Create symbol data for any indirect symbols.
691689
bindIndirectSymbols(Asm);

llvm/lib/MC/SPIRVObjectWriter.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ class SPIRVObjectWriter : public MCObjectWriter {
3333
const MCFixup &Fixup, MCValue Target,
3434
uint64_t &FixedValue) override {}
3535

36-
void executePostLayoutBinding(MCAssembler &Asm,
37-
const MCAsmLayout &Layout) override {}
38-
3936
uint64_t writeObject(MCAssembler &Asm) override;
4037
void writeHeader(const MCAssembler &Asm);
4138
};

llvm/lib/MC/WasmObjectWriter.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,8 +297,7 @@ class WasmObjectWriter : public MCObjectWriter {
297297
const MCFixup &Fixup, MCValue Target,
298298
uint64_t &FixedValue) override;
299299

300-
void executePostLayoutBinding(MCAssembler &Asm,
301-
const MCAsmLayout &Layout) override;
300+
void executePostLayoutBinding(MCAssembler &Asm) override;
302301
void prepareImports(SmallVectorImpl<wasm::WasmImport> &Imports,
303302
MCAssembler &Asm, const MCAsmLayout &Layout);
304303
uint64_t writeObject(MCAssembler &Asm) override;
@@ -452,8 +451,7 @@ void WasmObjectWriter::writeHeader(const MCAssembler &Asm) {
452451
W->write<uint32_t>(wasm::WasmVersion);
453452
}
454453

455-
void WasmObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
456-
const MCAsmLayout &Layout) {
454+
void WasmObjectWriter::executePostLayoutBinding(MCAssembler &Asm) {
457455
// Some compilation units require the indirect function table to be present
458456
// but don't explicitly reference it. This is the case for call_indirect
459457
// without the reference-types feature, and also function bitcasts in all

llvm/lib/MC/WinCOFFObjectWriter.cpp

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class WinCOFFWriter {
161161
DwoMode Mode);
162162

163163
void reset();
164-
void executePostLayoutBinding(MCAssembler &Asm, const MCAsmLayout &Layout);
164+
void executePostLayoutBinding(MCAssembler &Asm);
165165
void recordRelocation(MCAssembler &Asm, const MCFragment *Fragment,
166166
const MCFixup &Fixup, MCValue Target,
167167
uint64_t &FixedValue);
@@ -223,8 +223,7 @@ class WinCOFFObjectWriter : public MCObjectWriter {
223223

224224
// MCObjectWriter interface implementation.
225225
void reset() override;
226-
void executePostLayoutBinding(MCAssembler &Asm,
227-
const MCAsmLayout &Layout) override;
226+
void executePostLayoutBinding(MCAssembler &Asm) override;
228227
bool isSymbolRefDifferenceFullyResolvedImpl(const MCAssembler &Asm,
229228
const MCSymbol &SymA,
230229
const MCFragment &FB, bool InSet,
@@ -834,8 +833,8 @@ void WinCOFFWriter::reset() {
834833
WeakDefaults.clear();
835834
}
836835

837-
void WinCOFFWriter::executePostLayoutBinding(MCAssembler &Asm,
838-
const MCAsmLayout &Layout) {
836+
void WinCOFFWriter::executePostLayoutBinding(MCAssembler &Asm) {
837+
auto &Layout = *Asm.getLayout();
839838
// "Define" each section & symbol. This creates section & symbol
840839
// entries in the staging area.
841840
for (const auto &Section : Asm) {
@@ -1204,11 +1203,10 @@ bool WinCOFFObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(
12041203
return &SymA.getSection() == FB.getParent();
12051204
}
12061205

1207-
void WinCOFFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
1208-
const MCAsmLayout &Layout) {
1209-
ObjWriter->executePostLayoutBinding(Asm, Layout);
1206+
void WinCOFFObjectWriter::executePostLayoutBinding(MCAssembler &Asm) {
1207+
ObjWriter->executePostLayoutBinding(Asm);
12101208
if (DwoWriter)
1211-
DwoWriter->executePostLayoutBinding(Asm, Layout);
1209+
DwoWriter->executePostLayoutBinding(Asm);
12121210
}
12131211

12141212
void WinCOFFObjectWriter::recordRelocation(MCAssembler &Asm,

llvm/lib/MC/XCOFFObjectWriter.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ class XCOFFObjectWriter : public MCObjectWriter {
351351

352352
void reset() override;
353353

354-
void executePostLayoutBinding(MCAssembler &, const MCAsmLayout &) override;
354+
void executePostLayoutBinding(MCAssembler &) override;
355355

356356
void recordRelocation(MCAssembler &, const MCFragment *, const MCFixup &,
357357
MCValue, uint64_t &) override;
@@ -559,8 +559,7 @@ static MCSectionXCOFF *getContainingCsect(const MCSymbolXCOFF *XSym) {
559559
return XSym->getRepresentedCsect();
560560
}
561561

562-
void XCOFFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
563-
const MCAsmLayout &Layout) {
562+
void XCOFFObjectWriter::executePostLayoutBinding(MCAssembler &Asm) {
564563
for (const auto &S : Asm) {
565564
const auto *MCSec = cast<const MCSectionXCOFF>(&S);
566565
assert(!SectionMap.contains(MCSec) && "Cannot add a section twice.");
@@ -656,7 +655,7 @@ void XCOFFObjectWriter::executePostLayoutBinding(MCAssembler &Asm,
656655
Strings.add(Vers);
657656

658657
Strings.finalize();
659-
assignAddressesAndIndices(Asm, Layout);
658+
assignAddressesAndIndices(Asm, *Asm.getLayout());
660659
}
661660

662661
void XCOFFObjectWriter::recordRelocation(MCAssembler &Asm,

0 commit comments

Comments
 (0)