@@ -118,6 +118,7 @@ class MCAssembler {
118
118
std::unique_ptr<MCCodeEmitter> Emitter;
119
119
std::unique_ptr<MCObjectWriter> Writer;
120
120
121
+ MCAsmLayout *Layout = nullptr ;
121
122
bool RelaxAll = false ;
122
123
bool SubsectionsViaSymbols = false ;
123
124
bool IncrementalLinkerCompatible = false ;
@@ -171,7 +172,6 @@ class MCAssembler {
171
172
// / Evaluate a fixup to a relocatable expression and the value which should be
172
173
// / placed into the fixup.
173
174
// /
174
- // / \param Layout The layout to use for evaluation.
175
175
// / \param Fixup The fixup to evaluate.
176
176
// / \param DF The fragment the fixup is inside.
177
177
// / \param Target [out] On return, the relocatable expression the fixup
@@ -183,45 +183,38 @@ class MCAssembler {
183
183
// / \return Whether the fixup value was fully resolved. This is true if the
184
184
// / \p Value result is fixed, otherwise the value may change due to
185
185
// / relocation.
186
- bool evaluateFixup (const MCAsmLayout &Layout, const MCFixup &Fixup,
187
- const MCFragment *DF, MCValue &Target,
188
- const MCSubtargetInfo *STI, uint64_t &Value,
189
- bool &WasForced) const ;
186
+ bool evaluateFixup (const MCFixup &Fixup, const MCFragment *DF,
187
+ MCValue &Target, const MCSubtargetInfo *STI,
188
+ uint64_t &Value, bool &WasForced) const ;
190
189
191
190
// / Check whether a fixup can be satisfied, or whether it needs to be relaxed
192
191
// / (increased in size, in order to hold its value correctly).
193
- bool fixupNeedsRelaxation (const MCFixup &Fixup, const MCRelaxableFragment *DF,
194
- const MCAsmLayout &Layout) const ;
192
+ bool fixupNeedsRelaxation (const MCFixup &Fixup, const MCRelaxableFragment *DF) const ;
195
193
196
194
// / Check whether the given fragment needs relaxation.
197
- bool fragmentNeedsRelaxation (const MCRelaxableFragment *IF,
198
- const MCAsmLayout &Layout) const ;
195
+ bool fragmentNeedsRelaxation (const MCRelaxableFragment *IF) const ;
199
196
200
197
// / Perform one layout iteration and return true if any offsets
201
198
// / were adjusted.
202
- bool layoutOnce (MCAsmLayout &Layout );
199
+ bool layoutOnce ();
203
200
204
201
// / Perform relaxation on a single fragment - returns true if the fragment
205
202
// / changes as a result of relaxation.
206
- bool relaxFragment (MCAsmLayout &Layout, MCFragment &F);
207
- bool relaxInstruction (MCAsmLayout &Layout, MCRelaxableFragment &IF);
208
- bool relaxLEB (MCAsmLayout &Layout, MCLEBFragment &IF);
209
- bool relaxBoundaryAlign (MCAsmLayout &Layout, MCBoundaryAlignFragment &BF);
210
- bool relaxDwarfLineAddr (MCAsmLayout &Layout, MCDwarfLineAddrFragment &DF);
211
- bool relaxDwarfCallFrameFragment (MCAsmLayout &Layout,
212
- MCDwarfCallFrameFragment &DF);
213
- bool relaxCVInlineLineTable (MCAsmLayout &Layout,
214
- MCCVInlineLineTableFragment &DF);
215
- bool relaxCVDefRange (MCAsmLayout &Layout, MCCVDefRangeFragment &DF);
216
- bool relaxPseudoProbeAddr (MCAsmLayout &Layout, MCPseudoProbeAddrFragment &DF);
203
+ bool relaxFragment (MCFragment &F);
204
+ bool relaxInstruction (MCRelaxableFragment &IF);
205
+ bool relaxLEB (MCLEBFragment &IF);
206
+ bool relaxBoundaryAlign (MCBoundaryAlignFragment &BF);
207
+ bool relaxDwarfLineAddr (MCDwarfLineAddrFragment &DF);
208
+ bool relaxDwarfCallFrameFragment (MCDwarfCallFrameFragment &DF);
209
+ bool relaxCVInlineLineTable (MCCVInlineLineTableFragment &DF);
210
+ bool relaxCVDefRange (MCCVDefRangeFragment &DF);
211
+ bool relaxPseudoProbeAddr (MCPseudoProbeAddrFragment &DF);
217
212
218
213
// / finishLayout - Finalize a layout, including fragment lowering.
219
214
void finishLayout (MCAsmLayout &Layout);
220
215
221
- std::tuple<MCValue, uint64_t , bool > handleFixup (const MCAsmLayout &Layout,
222
- MCFragment &F,
223
- const MCFixup &Fixup,
224
- const MCSubtargetInfo *STI);
216
+ std::tuple<MCValue, uint64_t , bool >
217
+ handleFixup (MCFragment &F, const MCFixup &Fixup, const MCSubtargetInfo *STI);
225
218
226
219
public:
227
220
struct Symver {
@@ -246,10 +239,28 @@ class MCAssembler {
246
239
MCAssembler &operator =(const MCAssembler &) = delete ;
247
240
~MCAssembler ();
248
241
249
- // / Compute the effective fragment size assuming it is laid out at the given
250
- // / \p SectionAddress and \p FragmentOffset.
251
- uint64_t computeFragmentSize (const MCAsmLayout &Layout,
252
- const MCFragment &F) const ;
242
+ // / Compute the effective fragment size.
243
+ uint64_t computeFragmentSize (const MCFragment &F) const ;
244
+
245
+ void layoutBundle (MCFragment *Prev, MCFragment *F) const ;
246
+ void ensureValid (MCSection &Sec) const ;
247
+
248
+ // Get the offset of the given fragment inside its containing section.
249
+ uint64_t getFragmentOffset (const MCFragment &F) const ;
250
+
251
+ uint64_t getSectionAddressSize (const MCSection &Sec) const ;
252
+ uint64_t getSectionFileSize (const MCSection &Sec) const ;
253
+
254
+ // Get the offset of the given symbol, as computed in the current
255
+ // layout.
256
+ // \return True on success.
257
+ bool getSymbolOffset (const MCSymbol &S, uint64_t &Val) const ;
258
+
259
+ // Variant that reports a fatal error if the offset is not computable.
260
+ uint64_t getSymbolOffset (const MCSymbol &S) const ;
261
+
262
+ // If this symbol is equivalent to A + Constant, return A.
263
+ const MCSymbol *getBaseSymbol (const MCSymbol &Symbol) const ;
253
264
254
265
// / Check whether a particular symbol is visible to the linker and is required
255
266
// / in the symbol table, or whether it can be discarded by the assembler. This
@@ -349,6 +360,8 @@ class MCAssembler {
349
360
IncrementalLinkerCompatible = Value;
350
361
}
351
362
363
+ MCAsmLayout *getLayout () const { return Layout; }
364
+ bool hasLayout () const { return Layout; }
352
365
bool getRelaxAll () const { return RelaxAll; }
353
366
void setRelaxAll (bool Value) { RelaxAll = Value; }
354
367
0 commit comments