@@ -278,9 +278,6 @@ class GOFFWriter {
278
278
GOFFOstream OS;
279
279
[[maybe_unused]] MCAssembler &Asm;
280
280
281
- // / Counter for symbol id's.
282
- uint32_t EsdIdCounter = 0 ;
283
-
284
281
void writeHeader ();
285
282
void writeSymbol (const GOFFSymbol &Symbol);
286
283
void writeEnd ();
@@ -300,21 +297,21 @@ GOFFWriter::GOFFWriter(raw_pwrite_stream &OS, MCAssembler &Asm)
300
297
301
298
void GOFFWriter::defineSectionSymbols (const MCSectionGOFF &Section) {
302
299
if (Section.isSD ()) {
303
- GOFFSymbol SD (Section.getName (), Section.getId (),
300
+ GOFFSymbol SD (Section.getName (), Section.getOrdinal (),
304
301
Section.getSDAttributes ());
305
302
writeSymbol (SD);
306
303
}
307
304
308
305
if (Section.isED ()) {
309
- GOFFSymbol ED (Section.getName (), Section.getId (),
310
- Section.getParent ()->getId (), Section.getEDAttributes ());
306
+ GOFFSymbol ED (Section.getName (), Section.getOrdinal (),
307
+ Section.getParent ()->getOrdinal (), Section.getEDAttributes ());
311
308
ED.SectionLength = Asm.getSectionAddressSize (Section);
312
309
writeSymbol (ED);
313
310
}
314
311
315
312
if (Section.isPR ()) {
316
- GOFFSymbol PR (Section.getName (), Section.getId (),
317
- Section.getParent ()->getId (), Section.getPRAttributes ());
313
+ GOFFSymbol PR (Section.getName (), Section.getOrdinal (),
314
+ Section.getParent ()->getOrdinal (), Section.getPRAttributes ());
318
315
PR.SectionLength = Asm.getSectionAddressSize (Section);
319
316
if (Section.requiresNonZeroLength ()) {
320
317
// We cannot have a zero-length section for data. If we do,
@@ -330,20 +327,21 @@ void GOFFWriter::defineSectionSymbols(const MCSectionGOFF &Section) {
330
327
}
331
328
332
329
void GOFFWriter::defineLabel (const MCSymbolGOFF &Symbol) {
333
- GOFFSymbol LD (Symbol.getName (), ++EsdIdCounter ,
334
- static_cast <MCSectionGOFF &>(Symbol.getSection ()).getId (),
330
+ GOFFSymbol LD (Symbol.getName (), Symbol. getIndex () ,
331
+ static_cast <MCSectionGOFF &>(Symbol.getSection ()).getOrdinal (),
335
332
Symbol.getLDAttributes ());
336
333
if (Symbol.getADA ())
337
- LD.ADAEsdId = Symbol.getADA ()->getId ();
334
+ LD.ADAEsdId = Symbol.getADA ()->getOrdinal ();
338
335
writeSymbol (LD);
339
336
}
340
337
341
338
void GOFFWriter::defineSymbols () {
339
+ unsigned Ordinal = 0 ;
342
340
// Process all sections.
343
341
for (MCSection &S : Asm) {
344
342
auto &Section = cast<MCSectionGOFF>(S);
343
+ Section.setOrdinal (++Ordinal);
345
344
defineSectionSymbols (Section);
346
- EsdIdCounter = std::max (EsdIdCounter, Section.getId ());
347
345
}
348
346
349
347
// Process all symbols
@@ -352,6 +350,7 @@ void GOFFWriter::defineSymbols() {
352
350
continue ;
353
351
auto &Symbol = cast<MCSymbolGOFF>(Sym);
354
352
if (Symbol.hasLDAttributes ()) {
353
+ Symbol.setIndex (++Ordinal);
355
354
defineLabel (Symbol);
356
355
}
357
356
}
0 commit comments