Skip to content

Commit eb22392

Browse files
committed
MCAssembler: Move LinkerOptions to MachObjectWriter
1 parent ae3c85a commit eb22392

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

llvm/include/llvm/MC/MCAssembler.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,6 @@ class MCAssembler {
7171

7272
SmallVector<const MCSymbol *, 0> Symbols;
7373

74-
/// The list of linker options to propagate into the object file.
75-
std::vector<std::vector<std::string>> LinkerOptions;
76-
7774
MCDwarfLineTableParams LTParams;
7875

7976
/// The set of function symbols for which a .thumb_func directive has
@@ -236,10 +233,6 @@ class MCAssembler {
236233
return make_pointee_range(Symbols);
237234
}
238235

239-
std::vector<std::vector<std::string>> &getLinkerOptions() {
240-
return LinkerOptions;
241-
}
242-
243236
bool registerSection(MCSection &Section);
244237
bool registerSymbol(const MCSymbol &Symbol);
245238

llvm/include/llvm/MC/MCMachObjectWriter.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ class MachObjectWriter : public MCObjectWriter {
164164
VersionInfoType VersionInfo{};
165165
VersionInfoType TargetVariantVersionInfo{};
166166

167+
// The list of linker options for LC_LINKER_OPTION.
168+
std::vector<std::vector<std::string>> LinkerOptions;
169+
167170
MachSymbolData *findSymbolData(const MCSymbol &Sym);
168171

169172
void writeWithPadding(StringRef Str, uint64_t Size);
@@ -249,6 +252,10 @@ class MachObjectWriter : public MCObjectWriter {
249252
TargetVariantVersionInfo.SDKVersion = SDKVersion;
250253
}
251254

255+
std::vector<std::vector<std::string>> &getLinkerOptions() {
256+
return LinkerOptions;
257+
}
258+
252259
/// @}
253260

254261
/// \name Target Writer Proxy Accessors

llvm/lib/MC/MCAssembler.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ void MCAssembler::reset() {
9393
SubsectionsViaSymbols = false;
9494
Sections.clear();
9595
Symbols.clear();
96-
LinkerOptions.clear();
9796
ThumbFuncs.clear();
9897
BundleAlignSize = 0;
9998

llvm/lib/MC/MCMachOStreamer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ void MCMachOStreamer::emitAssemblerFlag(MCAssemblerFlag Flag) {
226226
}
227227

228228
void MCMachOStreamer::emitLinkerOptions(ArrayRef<std::string> Options) {
229-
getAssembler().getLinkerOptions().push_back(Options);
229+
getWriter().getLinkerOptions().push_back(Options);
230230
}
231231

232232
void MCMachOStreamer::emitDataRegion(MCDataRegionType Kind) {

llvm/lib/MC/MachObjectWriter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ void MachObjectWriter::reset() {
6060
VersionInfo.SDKVersion = VersionTuple();
6161
TargetVariantVersionInfo.Major = 0;
6262
TargetVariantVersionInfo.SDKVersion = VersionTuple();
63+
LinkerOptions.clear();
6364
MCObjectWriter::reset();
6465
}
6566

@@ -857,7 +858,7 @@ uint64_t MachObjectWriter::writeObject(MCAssembler &Asm) {
857858
}
858859

859860
// Add the linker option load commands sizes.
860-
for (const auto &Option : Asm.getLinkerOptions()) {
861+
for (const auto &Option : LinkerOptions) {
861862
++NumLoadCommands;
862863
LoadCommandsSize += ComputeLinkerOptionsLoadCommandSize(Option, is64Bit());
863864
}
@@ -1016,7 +1017,7 @@ uint64_t MachObjectWriter::writeObject(MCAssembler &Asm) {
10161017
}
10171018

10181019
// Write the linker options load commands.
1019-
for (const auto &Option : Asm.getLinkerOptions())
1020+
for (const auto &Option : LinkerOptions)
10201021
writeLinkerOptionsLoadCommand(Option);
10211022

10221023
// Write the actual section data.

0 commit comments

Comments
 (0)