@@ -86,6 +86,12 @@ class MCMachObjectTargetWriter : public MCObjectTargetWriter {
86
86
87
87
class MachObjectWriter : public MCObjectWriter {
88
88
public:
89
+ struct DataRegionData {
90
+ MachO::DataRegionType Kind;
91
+ MCSymbol *Start;
92
+ MCSymbol *End;
93
+ };
94
+
89
95
// A Major version of 0 indicates that no version information was supplied
90
96
// and so the corresponding load command should not be emitted.
91
97
using VersionInfoType = struct {
@@ -112,6 +118,11 @@ class MachObjectWriter : public MCObjectWriter {
112
118
bool operator <(const MachSymbolData &RHS) const ;
113
119
};
114
120
121
+ struct IndirectSymbolData {
122
+ MCSymbol *Symbol;
123
+ MCSection *Section;
124
+ };
125
+
115
126
// / The target specific Mach-O writer instance.
116
127
std::unique_ptr<MCMachObjectTargetWriter> TargetObjectWriter;
117
128
@@ -132,8 +143,11 @@ class MachObjectWriter : public MCObjectWriter {
132
143
133
144
private:
134
145
DenseMap<const MCSection *, std::vector<RelAndSymbol>> Relocations;
146
+ std::vector<IndirectSymbolData> IndirectSymbols;
135
147
DenseMap<const MCSection *, unsigned > IndirectSymBase;
136
148
149
+ std::vector<DataRegionData> DataRegions;
150
+
137
151
SectionAddrMap SectionAddress;
138
152
139
153
// List of sections in layout order. Virtual sections are after non-virtual
@@ -151,12 +165,18 @@ class MachObjectWriter : public MCObjectWriter {
151
165
152
166
// / @}
153
167
168
+ // Used to communicate Linker Optimization Hint information.
169
+ MCLOHContainer LOHContainer;
170
+
154
171
VersionInfoType VersionInfo{};
155
172
VersionInfoType TargetVariantVersionInfo{};
156
173
157
174
std::optional<unsigned > PtrAuthABIVersion = std::nullopt;
158
175
bool PtrAuthKernelABIVersion = false ;
159
176
177
+ // The list of linker options for LC_LINKER_OPTION.
178
+ std::vector<std::vector<std::string>> LinkerOptions;
179
+
160
180
MachSymbolData *findSymbolData (const MCSymbol &Sym);
161
181
162
182
void writeWithPadding (StringRef Str, uint64_t Size);
@@ -194,10 +214,15 @@ class MachObjectWriter : public MCObjectWriter {
194
214
195
215
bool isFixupKindPCRel (const MCAssembler &Asm, unsigned Kind);
196
216
217
+ std::vector<IndirectSymbolData> &getIndirectSymbols () {
218
+ return IndirectSymbols;
219
+ }
220
+ std::vector<DataRegionData> &getDataRegions () { return DataRegions; }
197
221
const llvm::SmallVectorImpl<MCSection *> &getSectionOrder () const {
198
222
return SectionOrder;
199
223
}
200
224
SectionAddrMap &getSectionAddressMap () { return SectionAddress; }
225
+ MCLOHContainer &getLOHContainer () { return LOHContainer; }
201
226
202
227
uint64_t getSectionAddress (const MCSection *Sec) const {
203
228
return SectionAddress.lookup (Sec);
@@ -216,45 +241,43 @@ class MachObjectWriter : public MCObjectWriter {
216
241
// / Mach-O deployment target version information.
217
242
void setVersionMin (MCVersionMinType Type, unsigned Major, unsigned Minor,
218
243
unsigned Update,
219
- VersionTuple SDKVersion = VersionTuple()) override {
244
+ VersionTuple SDKVersion = VersionTuple()) {
220
245
VersionInfo.EmitBuildVersion = false ;
221
246
VersionInfo.TypeOrPlatform .Type = Type;
222
247
VersionInfo.Major = Major;
223
248
VersionInfo.Minor = Minor;
224
249
VersionInfo.Update = Update;
225
250
VersionInfo.SDKVersion = SDKVersion;
226
251
}
227
- void setBuildVersion (unsigned Platform, unsigned Major, unsigned Minor ,
228
- unsigned Update,
229
- VersionTuple SDKVersion = VersionTuple()) override {
252
+ void setBuildVersion (MachO::PlatformType Platform, unsigned Major,
253
+ unsigned Minor, unsigned Update,
254
+ VersionTuple SDKVersion = VersionTuple()) {
230
255
VersionInfo.EmitBuildVersion = true ;
231
- VersionInfo.TypeOrPlatform .Platform = (MachO::PlatformType) Platform;
256
+ VersionInfo.TypeOrPlatform .Platform = Platform;
232
257
VersionInfo.Major = Major;
233
258
VersionInfo.Minor = Minor;
234
259
VersionInfo.Update = Update;
235
260
VersionInfo.SDKVersion = SDKVersion;
236
261
}
237
- void setTargetVariantBuildVersion (unsigned Platform, unsigned Major ,
238
- unsigned Minor , unsigned Update ,
239
- VersionTuple SDKVersion) override {
262
+ void setTargetVariantBuildVersion (MachO::PlatformType Platform,
263
+ unsigned Major , unsigned Minor ,
264
+ unsigned Update, VersionTuple SDKVersion) {
240
265
TargetVariantVersionInfo.EmitBuildVersion = true ;
241
- TargetVariantVersionInfo.TypeOrPlatform .Platform =
242
- (MachO::PlatformType)Platform;
266
+ TargetVariantVersionInfo.TypeOrPlatform .Platform = Platform;
243
267
TargetVariantVersionInfo.Major = Major;
244
268
TargetVariantVersionInfo.Minor = Minor;
245
269
TargetVariantVersionInfo.Update = Update;
246
270
TargetVariantVersionInfo.SDKVersion = SDKVersion;
247
271
}
248
272
249
- std::optional<unsigned > getPtrAuthABIVersion () const override {
273
+ std::optional<unsigned > getPtrAuthABIVersion () const {
250
274
return PtrAuthABIVersion;
251
275
}
252
- void setPtrAuthABIVersion (unsigned V) override { PtrAuthABIVersion = V; }
253
- bool getPtrAuthKernelABIVersion () const override {
254
- return PtrAuthKernelABIVersion;
255
- }
256
- void setPtrAuthKernelABIVersion (bool V) override {
257
- PtrAuthKernelABIVersion = V;
276
+ void setPtrAuthABIVersion (unsigned V) { PtrAuthABIVersion = V; }
277
+ bool getPtrAuthKernelABIVersion () const { return PtrAuthKernelABIVersion; }
278
+ void setPtrAuthKernelABIVersion (bool V) { PtrAuthKernelABIVersion = V; }
279
+ std::vector<std::vector<std::string>> &getLinkerOptions () {
280
+ return LinkerOptions;
258
281
}
259
282
260
283
// / @}
0 commit comments