[llvm] 23e6224 - [MC] Remove the MCAsmLayout parameter from MCObjectWriter::{writeObject,writeSectionData}
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 1 10:05:03 PDT 2024
Author: Fangrui Song
Date: 2024-07-01T10:04:59-07:00
New Revision: 23e62243746a1c43e4e6251fcab178498afc3426
URL: https://github.com/llvm/llvm-project/commit/23e62243746a1c43e4e6251fcab178498afc3426
DIFF: https://github.com/llvm/llvm-project/commit/23e62243746a1c43e4e6251fcab178498afc3426.diff
LOG: [MC] Remove the MCAsmLayout parameter from MCObjectWriter::{writeObject,writeSectionData}
Added:
Modified:
llvm/include/llvm/MC/MCAssembler.h
llvm/include/llvm/MC/MCMachObjectWriter.h
llvm/include/llvm/MC/MCObjectWriter.h
llvm/lib/MC/ELFObjectWriter.cpp
llvm/lib/MC/GOFFObjectWriter.cpp
llvm/lib/MC/MCAssembler.cpp
llvm/lib/MC/MCDXContainerWriter.cpp
llvm/lib/MC/MachObjectWriter.cpp
llvm/lib/MC/SPIRVObjectWriter.cpp
llvm/lib/MC/WasmObjectWriter.cpp
llvm/lib/MC/WinCOFFObjectWriter.cpp
llvm/lib/MC/XCOFFObjectWriter.cpp
llvm/tools/dsymutil/MachOUtils.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/MC/MCAssembler.h b/llvm/include/llvm/MC/MCAssembler.h
index 53588139f7fac..cc0267ea4c220 100644
--- a/llvm/include/llvm/MC/MCAssembler.h
+++ b/llvm/include/llvm/MC/MCAssembler.h
@@ -269,8 +269,7 @@ class MCAssembler {
bool isSymbolLinkerVisible(const MCSymbol &SD) const;
/// Emit the section contents to \p OS.
- void writeSectionData(raw_ostream &OS, const MCSection *Section,
- const MCAsmLayout &Layout) const;
+ void writeSectionData(raw_ostream &OS, const MCSection *Section) const;
/// Check whether a given symbol has been flagged with .thumb_func.
bool isThumbFunc(const MCSymbol *Func) const;
diff --git a/llvm/include/llvm/MC/MCMachObjectWriter.h b/llvm/include/llvm/MC/MCMachObjectWriter.h
index 4e538ed677fad..4eb7ad12c27c5 100644
--- a/llvm/include/llvm/MC/MCMachObjectWriter.h
+++ b/llvm/include/llvm/MC/MCMachObjectWriter.h
@@ -262,7 +262,7 @@ class MachObjectWriter : public MCObjectWriter {
void populateAddrSigSection(MCAssembler &Asm);
- uint64_t writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) override;
+ uint64_t writeObject(MCAssembler &Asm) override;
};
/// Construct a new Mach-O writer instance.
diff --git a/llvm/include/llvm/MC/MCObjectWriter.h b/llvm/include/llvm/MC/MCObjectWriter.h
index 2f5066adf6e1e..2d667714e2f12 100644
--- a/llvm/include/llvm/MC/MCObjectWriter.h
+++ b/llvm/include/llvm/MC/MCObjectWriter.h
@@ -115,7 +115,7 @@ class MCObjectWriter {
/// This routine is called by the assembler after layout and relaxation is
/// complete, fixups have been evaluated and applied, and relocations
/// generated.
- virtual uint64_t writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) = 0;
+ virtual uint64_t writeObject(MCAssembler &Asm) = 0;
/// @}
};
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index 5bd453a76232d..b744740414967 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -197,8 +197,7 @@ struct ELFWriter {
const SectionIndexMapTy &SectionIndexMap,
const SectionOffsetsTy &SectionOffsets);
- void writeSectionData(const MCAssembler &Asm, MCSection &Sec,
- const MCAsmLayout &Layout);
+ void writeSectionData(const MCAssembler &Asm, MCSection &Sec);
void WriteSecHdrEntry(uint32_t Name, uint32_t Type, uint64_t Flags,
uint64_t Address, uint64_t Offset, uint64_t Size,
@@ -207,7 +206,7 @@ struct ELFWriter {
void writeRelocations(const MCAssembler &Asm, const MCSectionELF &Sec);
- uint64_t writeObject(MCAssembler &Asm, const MCAsmLayout &Layout);
+ uint64_t writeObject(MCAssembler &Asm);
void writeSection(const SectionIndexMapTy &SectionIndexMap,
uint32_t GroupSymbolIndex, uint64_t Offset, uint64_t Size,
const MCSectionELF &Section);
@@ -282,9 +281,9 @@ class ELFSingleObjectWriter : public ELFObjectWriter {
: ELFObjectWriter(std::move(MOTW)), OS(OS),
IsLittleEndian(IsLittleEndian) {}
- uint64_t writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) override {
+ uint64_t writeObject(MCAssembler &Asm) override {
return ELFWriter(*this, OS, IsLittleEndian, ELFWriter::AllSections)
- .writeObject(Asm, Layout);
+ .writeObject(Asm);
}
friend struct ELFWriter;
@@ -314,11 +313,11 @@ class ELFDwoObjectWriter : public ELFObjectWriter {
return true;
}
- uint64_t writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) override {
+ uint64_t writeObject(MCAssembler &Asm) override {
uint64_t Size = ELFWriter(*this, OS, IsLittleEndian, ELFWriter::NonDwoOnly)
- .writeObject(Asm, Layout);
+ .writeObject(Asm);
Size += ELFWriter(*this, DwoOS, IsLittleEndian, ELFWriter::DwoOnly)
- .writeObject(Asm, Layout);
+ .writeObject(Asm);
return Size;
}
};
@@ -850,8 +849,7 @@ bool ELFWriter::maybeWriteCompression(
return true;
}
-void ELFWriter::writeSectionData(const MCAssembler &Asm, MCSection &Sec,
- const MCAsmLayout &Layout) {
+void ELFWriter::writeSectionData(const MCAssembler &Asm, MCSection &Sec) {
MCSectionELF &Section = static_cast<MCSectionELF &>(Sec);
StringRef SectionName = Section.getName();
auto &Ctx = Asm.getContext();
@@ -860,13 +858,13 @@ void ELFWriter::writeSectionData(const MCAssembler &Asm, MCSection &Sec,
: DebugCompressionType::None;
if (CompressionType == DebugCompressionType::None ||
!SectionName.starts_with(".debug_")) {
- Asm.writeSectionData(W.OS, &Section, Layout);
+ Asm.writeSectionData(W.OS, &Section);
return;
}
SmallVector<char, 128> UncompressedData;
raw_svector_ostream VecOS(UncompressedData);
- Asm.writeSectionData(VecOS, &Section, Layout);
+ Asm.writeSectionData(VecOS, &Section);
ArrayRef<uint8_t> Uncompressed =
ArrayRef(reinterpret_cast<uint8_t *>(UncompressedData.data()),
UncompressedData.size());
@@ -1066,7 +1064,8 @@ void ELFWriter::writeSectionHeader(
}
}
-uint64_t ELFWriter::writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) {
+uint64_t ELFWriter::writeObject(MCAssembler &Asm) {
+ auto &Layout = *Asm.getLayout();
uint64_t StartOffset = W.OS.tell();
MCContext &Ctx = Asm.getContext();
@@ -1097,7 +1096,7 @@ uint64_t ELFWriter::writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) {
const uint64_t SecStart = align(Section.getAlign());
const MCSymbolELF *SignatureSymbol = Section.getGroup();
- writeSectionData(Asm, Section, Layout);
+ writeSectionData(Asm, Section);
uint64_t SecEnd = W.OS.tell();
SectionOffsets[&Section] = std::make_pair(SecStart, SecEnd);
diff --git a/llvm/lib/MC/GOFFObjectWriter.cpp b/llvm/lib/MC/GOFFObjectWriter.cpp
index c2f7653600778..d1b84496fd3be 100644
--- a/llvm/lib/MC/GOFFObjectWriter.cpp
+++ b/llvm/lib/MC/GOFFObjectWriter.cpp
@@ -241,7 +241,7 @@ class GOFFObjectWriter : public MCObjectWriter {
uint64_t &FixedValue) override {}
void executePostLayoutBinding(MCAssembler &Asm,
const MCAsmLayout &Layout) override {}
- uint64_t writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) override;
+ uint64_t writeObject(MCAssembler &Asm) override;
};
} // end anonymous namespace
@@ -278,8 +278,7 @@ void GOFFObjectWriter::writeEnd() {
OS.finalize();
}
-uint64_t GOFFObjectWriter::writeObject(MCAssembler &Asm,
- const MCAsmLayout &Layout) {
+uint64_t GOFFObjectWriter::writeObject(MCAssembler &Asm) {
uint64_t StartOffset = OS.tell();
writeHeader();
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index da840b0957c88..1e9c2f65ee057 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -667,7 +667,7 @@ void MCAssembler::writeFragmentPadding(raw_ostream &OS,
/// Write the fragment \p F to the output file.
static void writeFragment(raw_ostream &OS, const MCAssembler &Asm,
- const MCAsmLayout &Layout, const MCFragment &F) {
+ const MCFragment &F) {
// FIXME: Embed in fragments instead?
uint64_t FragmentSize = Asm.computeFragmentSize(F);
@@ -884,13 +884,13 @@ static void writeFragment(raw_ostream &OS, const MCAssembler &Asm,
"The stream should advance by fragment size");
}
-void MCAssembler::writeSectionData(raw_ostream &OS, const MCSection *Sec,
- const MCAsmLayout &Layout) const {
+void MCAssembler::writeSectionData(raw_ostream &OS,
+ const MCSection *Sec) const {
assert(getBackendPtr() && "Expected assembler backend");
// Ignore virtual sections.
if (Sec->isVirtualSection()) {
- assert(Layout.getSectionFileSize(Sec) == 0 && "Invalid size for section!");
+ assert(getSectionFileSize(*Sec) == 0 && "Invalid size for section!");
// Check that contents are only things legal inside a virtual section.
for (const MCFragment &F : *Sec) {
@@ -938,10 +938,10 @@ void MCAssembler::writeSectionData(raw_ostream &OS, const MCSection *Sec,
(void)Start;
for (const MCFragment &F : *Sec)
- writeFragment(OS, *this, Layout, F);
+ writeFragment(OS, *this, F);
assert(getContext().hadError() ||
- OS.tell() - Start == Layout.getSectionAddressSize(Sec));
+ OS.tell() - Start == getSectionAddressSize(*Sec));
}
std::tuple<MCValue, uint64_t, bool>
@@ -1109,7 +1109,7 @@ void MCAssembler::Finish() {
layout(Layout);
// Write the object file.
- stats::ObjectBytes += getWriter().writeObject(*this, Layout);
+ stats::ObjectBytes += getWriter().writeObject(*this);
this->Layout = nullptr;
}
diff --git a/llvm/lib/MC/MCDXContainerWriter.cpp b/llvm/lib/MC/MCDXContainerWriter.cpp
index 26d7146bb832e..337450fd8ae1b 100644
--- a/llvm/lib/MC/MCDXContainerWriter.cpp
+++ b/llvm/lib/MC/MCDXContainerWriter.cpp
@@ -42,19 +42,18 @@ class DXContainerObjectWriter : public MCObjectWriter {
void executePostLayoutBinding(MCAssembler &Asm,
const MCAsmLayout &Layout) override {}
- uint64_t writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) override;
+ uint64_t writeObject(MCAssembler &Asm) override;
};
} // namespace
-uint64_t DXContainerObjectWriter::writeObject(MCAssembler &Asm,
- const MCAsmLayout &Layout) {
+uint64_t DXContainerObjectWriter::writeObject(MCAssembler &Asm) {
// Start the file size as the header plus the size of the part offsets.
// Presently DXContainer files usually contain 7-10 parts. Reserving space for
// 16 part offsets gives us a little room for growth.
llvm::SmallVector<uint64_t, 16> PartOffsets;
uint64_t PartOffset = 0;
for (const MCSection &Sec : Asm) {
- uint64_t SectionSize = Layout.getSectionAddressSize(&Sec);
+ uint64_t SectionSize = Asm.getSectionAddressSize(Sec);
// Skip empty sections.
if (SectionSize == 0)
continue;
@@ -95,7 +94,7 @@ uint64_t DXContainerObjectWriter::writeObject(MCAssembler &Asm,
W.write<uint32_t>(static_cast<uint32_t>(PartStart + Offset));
for (const MCSection &Sec : Asm) {
- uint64_t SectionSize = Layout.getSectionAddressSize(&Sec);
+ uint64_t SectionSize = Asm.getSectionAddressSize(Sec);
// Skip empty sections.
if (SectionSize == 0)
continue;
@@ -139,7 +138,7 @@ uint64_t DXContainerObjectWriter::writeObject(MCAssembler &Asm,
W.write<char>(ArrayRef<char>(reinterpret_cast<char *>(&Header),
sizeof(dxbc::ProgramHeader)));
}
- Asm.writeSectionData(W.OS, &Sec, Layout);
+ Asm.writeSectionData(W.OS, &Sec);
unsigned Size = W.OS.tell() - Start;
W.OS.write_zeros(offsetToAlignment(Size, Align(4)));
}
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp
index 28eb95ab495b9..eea14593071fe 100644
--- a/llvm/lib/MC/MachObjectWriter.cpp
+++ b/llvm/lib/MC/MachObjectWriter.cpp
@@ -762,8 +762,8 @@ void MachObjectWriter::populateAddrSigSection(MCAssembler &Asm) {
}
}
-uint64_t MachObjectWriter::writeObject(MCAssembler &Asm,
- const MCAsmLayout &Layout) {
+uint64_t MachObjectWriter::writeObject(MCAssembler &Asm) {
+ auto &Layout = *Asm.getLayout();
uint64_t StartOffset = W.OS.tell();
populateAddrSigSection(Asm);
@@ -788,8 +788,7 @@ uint64_t MachObjectWriter::writeObject(MCAssembler &Asm,
}
unsigned NumSections = Asm.size();
- const MCAssembler::VersionInfoType &VersionInfo =
- Layout.getAssembler().getVersionInfo();
+ const MCAssembler::VersionInfoType &VersionInfo = Asm.getVersionInfo();
// The section data starts after the header, the segment load command (and
// section headers) and the symbol table.
@@ -808,7 +807,7 @@ uint64_t MachObjectWriter::writeObject(MCAssembler &Asm,
}
const MCAssembler::VersionInfoType &TargetVariantVersionInfo =
- Layout.getAssembler().getDarwinTargetVariantVersionInfo();
+ Asm.getDarwinTargetVariantVersionInfo();
// Add the target variant version info load command size, if used.
if (TargetVariantVersionInfo.Major != 0) {
@@ -857,8 +856,8 @@ uint64_t MachObjectWriter::writeObject(MCAssembler &Asm,
uint64_t VMSize = 0;
for (const MCSection &Sec : Asm) {
uint64_t Address = getSectionAddress(&Sec);
- uint64_t Size = Layout.getSectionAddressSize(&Sec);
- uint64_t FileSize = Layout.getSectionFileSize(&Sec);
+ uint64_t Size = Asm.getSectionAddressSize(Sec);
+ uint64_t FileSize = Asm.getSectionFileSize(Sec);
FileSize += getPaddingSize(&Sec, Layout);
VMSize = std::max(VMSize, Address + Size);
@@ -995,7 +994,7 @@ uint64_t MachObjectWriter::writeObject(MCAssembler &Asm,
// Write the actual section data.
for (const MCSection &Sec : Asm) {
- Asm.writeSectionData(W.OS, &Sec, Layout);
+ Asm.writeSectionData(W.OS, &Sec);
uint64_t Pad = getPaddingSize(&Sec, Layout);
W.OS.write_zeros(Pad);
diff --git a/llvm/lib/MC/SPIRVObjectWriter.cpp b/llvm/lib/MC/SPIRVObjectWriter.cpp
index 5ad146e3221ce..35b555489f42d 100644
--- a/llvm/lib/MC/SPIRVObjectWriter.cpp
+++ b/llvm/lib/MC/SPIRVObjectWriter.cpp
@@ -36,7 +36,7 @@ class SPIRVObjectWriter : public MCObjectWriter {
void executePostLayoutBinding(MCAssembler &Asm,
const MCAsmLayout &Layout) override {}
- uint64_t writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) override;
+ uint64_t writeObject(MCAssembler &Asm) override;
void writeHeader(const MCAssembler &Asm);
};
} // namespace
@@ -58,12 +58,11 @@ void SPIRVObjectWriter::writeHeader(const MCAssembler &Asm) {
W.write<uint32_t>(Schema);
}
-uint64_t SPIRVObjectWriter::writeObject(MCAssembler &Asm,
- const MCAsmLayout &Layout) {
+uint64_t SPIRVObjectWriter::writeObject(MCAssembler &Asm) {
uint64_t StartOffset = W.OS.tell();
writeHeader(Asm);
for (const MCSection &S : Asm)
- Asm.writeSectionData(W.OS, &S, Layout);
+ Asm.writeSectionData(W.OS, &S);
return W.OS.tell() - StartOffset;
}
diff --git a/llvm/lib/MC/WasmObjectWriter.cpp b/llvm/lib/MC/WasmObjectWriter.cpp
index 8109c83e31950..c621a378f4d15 100644
--- a/llvm/lib/MC/WasmObjectWriter.cpp
+++ b/llvm/lib/MC/WasmObjectWriter.cpp
@@ -301,7 +301,7 @@ class WasmObjectWriter : public MCObjectWriter {
const MCAsmLayout &Layout) override;
void prepareImports(SmallVectorImpl<wasm::WasmImport> &Imports,
MCAssembler &Asm, const MCAsmLayout &Layout);
- uint64_t writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) override;
+ uint64_t writeObject(MCAssembler &Asm) override;
uint64_t writeOneObject(MCAssembler &Asm, const MCAsmLayout &Layout,
DwoMode Mode);
@@ -1067,7 +1067,7 @@ uint32_t WasmObjectWriter::writeCodeSection(const MCAssembler &Asm,
int64_t Size = Layout.getSectionAddressSize(FuncSection);
encodeULEB128(Size, W->OS);
FuncSection->setSectionOffset(W->OS.tell() - Section.ContentsOffset);
- Asm.writeSectionData(W->OS, FuncSection, Layout);
+ Asm.writeSectionData(W->OS, FuncSection);
}
// Apply fixups.
@@ -1248,7 +1248,7 @@ void WasmObjectWriter::writeCustomSection(WasmCustomSection &CustomSection,
startCustomSection(Section, CustomSection.Name);
Sec->setSectionOffset(W->OS.tell() - Section.ContentsOffset);
- Asm.writeSectionData(W->OS, Sec, Layout);
+ Asm.writeSectionData(W->OS, Sec);
CustomSection.OutputContentsOffset = Section.ContentsOffset;
CustomSection.OutputIndex = Section.Index;
@@ -1438,8 +1438,8 @@ void WasmObjectWriter::prepareImports(
}
}
-uint64_t WasmObjectWriter::writeObject(MCAssembler &Asm,
- const MCAsmLayout &Layout) {
+uint64_t WasmObjectWriter::writeObject(MCAssembler &Asm) {
+ auto &Layout = *Asm.getLayout();
support::endian::Writer MainWriter(*OS, llvm::endianness::little);
W = &MainWriter;
if (IsSplitDwarf) {
diff --git a/llvm/lib/MC/WinCOFFObjectWriter.cpp b/llvm/lib/MC/WinCOFFObjectWriter.cpp
index 103dbe5629357..a795b2769eeac 100644
--- a/llvm/lib/MC/WinCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/WinCOFFObjectWriter.cpp
@@ -165,7 +165,7 @@ class WinCOFFWriter {
void recordRelocation(MCAssembler &Asm, const MCFragment *Fragment,
const MCFixup &Fixup, MCValue Target,
uint64_t &FixedValue);
- uint64_t writeObject(MCAssembler &Asm, const MCAsmLayout &Layout);
+ uint64_t writeObject(MCAssembler &Asm);
private:
COFFSymbol *createSymbol(StringRef Name);
@@ -232,7 +232,7 @@ class WinCOFFObjectWriter : public MCObjectWriter {
void recordRelocation(MCAssembler &Asm, const MCFragment *Fragment,
const MCFixup &Fixup, MCValue Target,
uint64_t &FixedValue) override;
- uint64_t writeObject(MCAssembler &Asm, const MCAsmLayout &Layout) override;
+ uint64_t writeObject(MCAssembler &Asm) override;
};
} // end anonymous namespace
@@ -600,7 +600,7 @@ void WinCOFFWriter::WriteRelocation(const COFF::relocation &R) {
}
// Write MCSec's contents. What this function does is essentially
-// "Asm.writeSectionData(&MCSec, Layout)", but it's a bit complicated
+// "Asm.writeSectionData(&MCSec)", but it's a bit complicated
// because it needs to compute a CRC.
uint32_t WinCOFFWriter::writeSectionContents(MCAssembler &Asm,
const MCAsmLayout &Layout,
@@ -609,7 +609,7 @@ uint32_t WinCOFFWriter::writeSectionContents(MCAssembler &Asm,
// to CRC the data before we dump it into the object file.
SmallVector<char, 128> Buf;
raw_svector_ostream VecOS(Buf);
- Asm.writeSectionData(VecOS, &MCSec, Layout);
+ Asm.writeSectionData(VecOS, &MCSec);
// Write the section contents to the object file.
W.OS << Buf;
@@ -1010,8 +1010,7 @@ static std::time_t getTime() {
return Now;
}
-uint64_t WinCOFFWriter::writeObject(MCAssembler &Asm,
- const MCAsmLayout &Layout) {
+uint64_t WinCOFFWriter::writeObject(MCAssembler &Asm) {
uint64_t StartOffset = W.OS.tell();
if (Sections.size() > INT32_MAX)
@@ -1131,7 +1130,7 @@ uint64_t WinCOFFWriter::writeObject(MCAssembler &Asm,
}
}
- assignFileOffsets(Asm, Layout);
+ assignFileOffsets(Asm, *Asm.getLayout());
// MS LINK expects to be able to use this timestamp to implement their
// /INCREMENTAL feature.
@@ -1161,7 +1160,7 @@ uint64_t WinCOFFWriter::writeObject(MCAssembler &Asm,
// Write section contents.
for (std::unique_ptr<COFFSection> &Sec : Sections)
- writeSection(Asm, Layout, *Sec);
+ writeSection(Asm, *Asm.getLayout(), *Sec);
assert(W.OS.tell() == Header.PointerToSymbolTable &&
"Header::PointerToSymbolTable is insane!");
@@ -1221,11 +1220,10 @@ void WinCOFFObjectWriter::recordRelocation(MCAssembler &Asm,
ObjWriter->recordRelocation(Asm, Fragment, Fixup, Target, FixedValue);
}
-uint64_t WinCOFFObjectWriter::writeObject(MCAssembler &Asm,
- const MCAsmLayout &Layout) {
- uint64_t TotalSize = ObjWriter->writeObject(Asm, Layout);
+uint64_t WinCOFFObjectWriter::writeObject(MCAssembler &Asm) {
+ uint64_t TotalSize = ObjWriter->writeObject(Asm);
if (DwoWriter)
- TotalSize += DwoWriter->writeObject(Asm, Layout);
+ TotalSize += DwoWriter->writeObject(Asm);
return TotalSize;
}
diff --git a/llvm/lib/MC/XCOFFObjectWriter.cpp b/llvm/lib/MC/XCOFFObjectWriter.cpp
index 070df492ad299..747968d270165 100644
--- a/llvm/lib/MC/XCOFFObjectWriter.cpp
+++ b/llvm/lib/MC/XCOFFObjectWriter.cpp
@@ -356,7 +356,7 @@ class XCOFFObjectWriter : public MCObjectWriter {
void recordRelocation(MCAssembler &, const MCFragment *, const MCFixup &,
MCValue, uint64_t &) override;
- uint64_t writeObject(MCAssembler &, const MCAsmLayout &) override;
+ uint64_t writeObject(MCAssembler &) override;
bool is64Bit() const { return TargetObjectWriter->is64Bit(); }
bool nameShouldBeInStringTable(const StringRef &);
@@ -377,7 +377,7 @@ class XCOFFObjectWriter : public MCObjectWriter {
void writeAuxFileHeader();
void writeSectionHeader(const SectionEntry *Sec);
void writeSectionHeaderTable();
- void writeSections(const MCAssembler &Asm, const MCAsmLayout &Layout);
+ void writeSections(const MCAssembler &Asm);
void writeSectionForControlSectionEntry(const MCAssembler &Asm,
const MCAsmLayout &Layout,
const CsectSectionEntry &CsectEntry,
@@ -393,7 +393,7 @@ class XCOFFObjectWriter : public MCObjectWriter {
const MCAsmLayout &Layout,
CInfoSymSectionEntry &CInfoSymEntry,
uint64_t &CurrentAddressLocation);
- void writeSymbolTable(MCAssembler &Asm, const MCAsmLayout &Layout);
+ void writeSymbolTable(MCAssembler &Asm);
void writeSymbolAuxFileEntry(StringRef &Name, uint8_t ftype);
void writeSymbolAuxDwarfEntry(uint64_t LengthOfSectionPortion,
uint64_t NumberOfRelocEnt = 0);
@@ -813,8 +813,8 @@ void XCOFFObjectWriter::recordRelocation(MCAssembler &Asm,
FixedValue -= getVirtualAddress(SymB, SymBSec);
}
-void XCOFFObjectWriter::writeSections(const MCAssembler &Asm,
- const MCAsmLayout &Layout) {
+void XCOFFObjectWriter::writeSections(const MCAssembler &Asm) {
+ auto &Layout = *Asm.getLayout();
uint64_t CurrentAddressLocation = 0;
for (const auto *Section : Sections)
writeSectionForControlSectionEntry(Asm, Layout, *Section,
@@ -828,8 +828,7 @@ void XCOFFObjectWriter::writeSections(const MCAssembler &Asm,
CurrentAddressLocation);
}
-uint64_t XCOFFObjectWriter::writeObject(MCAssembler &Asm,
- const MCAsmLayout &Layout) {
+uint64_t XCOFFObjectWriter::writeObject(MCAssembler &Asm) {
// We always emit a timestamp of 0 for reproducibility, so ensure incremental
// linking is not enabled, in case, like with Windows COFF, such a timestamp
// is incompatible with incremental linking of XCOFF.
@@ -842,9 +841,9 @@ uint64_t XCOFFObjectWriter::writeObject(MCAssembler &Asm,
writeFileHeader();
writeAuxFileHeader();
writeSectionHeaderTable();
- writeSections(Asm, Layout);
+ writeSections(Asm);
writeRelocations();
- writeSymbolTable(Asm, Layout);
+ writeSymbolTable(Asm);
// Write the string table.
Strings.write(W.OS);
@@ -1165,8 +1164,7 @@ void XCOFFObjectWriter::writeRelocations() {
writeRelocation(Reloc, *DwarfSection.DwarfSect);
}
-void XCOFFObjectWriter::writeSymbolTable(MCAssembler &Asm,
- const MCAsmLayout &Layout) {
+void XCOFFObjectWriter::writeSymbolTable(MCAssembler &Asm) {
// Write C_FILE symbols.
StringRef Vers = Asm.getCompilerVersion();
@@ -1237,7 +1235,7 @@ void XCOFFObjectWriter::writeSymbolTable(MCAssembler &Asm,
for (const auto &Sym : Csect.Syms)
writeSymbolEntryForCsectMemberLabel(
- Sym, Csect, SectionIndex, Layout.getSymbolOffset(*(Sym.MCSym)));
+ Sym, Csect, SectionIndex, Asm.getSymbolOffset(*(Sym.MCSym)));
}
}
}
@@ -1631,7 +1629,7 @@ void XCOFFObjectWriter::writeSectionForControlSectionEntry(
if (uint32_t PaddingSize = Csect.Address - CurrentAddressLocation)
W.OS.write_zeros(PaddingSize);
if (Csect.Size)
- Asm.writeSectionData(W.OS, Csect.MCSec, Layout);
+ Asm.writeSectionData(W.OS, Csect.MCSec);
CurrentAddressLocation = Csect.Address + Csect.Size;
}
}
@@ -1660,7 +1658,7 @@ void XCOFFObjectWriter::writeSectionForDwarfSectionEntry(
W.OS.write_zeros(PaddingSize);
if (DwarfEntry.Size)
- Asm.writeSectionData(W.OS, DwarfEntry.DwarfSect->MCSec, Layout);
+ Asm.writeSectionData(W.OS, DwarfEntry.DwarfSect->MCSec);
CurrentAddressLocation = DwarfEntry.Address + DwarfEntry.Size;
diff --git a/llvm/tools/dsymutil/MachOUtils.cpp b/llvm/tools/dsymutil/MachOUtils.cpp
index e2ec8cae22856..ff1b969826a22 100644
--- a/llvm/tools/dsymutil/MachOUtils.cpp
+++ b/llvm/tools/dsymutil/MachOUtils.cpp
@@ -631,7 +631,7 @@ bool generateDsymCompanion(
for (const MCSection &Sec : MCAsm) {
uint64_t Pos = OutFile.tell();
OutFile.write_zeros(alignTo(Pos, Sec.getAlign()) - Pos);
- MCAsm.writeSectionData(OutFile, &Sec, Layout);
+ MCAsm.writeSectionData(OutFile, &Sec);
}
// Apply relocations to the contents of the DWARF segment.
More information about the llvm-commits
mailing list