@@ -278,9 +278,6 @@ class GOFFWriter {
278278 GOFFOstream OS;
279279 [[maybe_unused]] MCAssembler &Asm;
280280
281- // / Counter for symbol id's.
282- uint32_t EsdIdCounter = 0 ;
283-
284281 void writeHeader ();
285282 void writeSymbol (const GOFFSymbol &Symbol);
286283 void writeEnd ();
@@ -300,21 +297,21 @@ GOFFWriter::GOFFWriter(raw_pwrite_stream &OS, MCAssembler &Asm)
300297
301298void GOFFWriter::defineSectionSymbols (const MCSectionGOFF &Section) {
302299 if (Section.isSD ()) {
303- GOFFSymbol SD (Section.getName (), Section.getId (),
300+ GOFFSymbol SD (Section.getName (), Section.getOrdinal (),
304301 Section.getSDAttributes ());
305302 writeSymbol (SD);
306303 }
307304
308305 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 ());
311308 ED.SectionLength = Asm.getSectionAddressSize (Section);
312309 writeSymbol (ED);
313310 }
314311
315312 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 ());
318315 PR.SectionLength = Asm.getSectionAddressSize (Section);
319316 if (Section.requiresNonZeroLength ()) {
320317 // We cannot have a zero-length section for data. If we do,
@@ -330,20 +327,21 @@ void GOFFWriter::defineSectionSymbols(const MCSectionGOFF &Section) {
330327}
331328
332329void 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 (),
335332 Symbol.getLDAttributes ());
336333 if (Symbol.getADA ())
337- LD.ADAEsdId = Symbol.getADA ()->getId ();
334+ LD.ADAEsdId = Symbol.getADA ()->getOrdinal ();
338335 writeSymbol (LD);
339336}
340337
341338void GOFFWriter::defineSymbols () {
339+ unsigned Ordinal = 0 ;
342340 // Process all sections.
343341 for (MCSection &S : Asm) {
344342 auto &Section = cast<MCSectionGOFF>(S);
343+ Section.setOrdinal (++Ordinal);
345344 defineSectionSymbols (Section);
346- EsdIdCounter = std::max (EsdIdCounter, Section.getId ());
347345 }
348346
349347 // Process all symbols
@@ -352,6 +350,7 @@ void GOFFWriter::defineSymbols() {
352350 continue ;
353351 auto &Symbol = cast<MCSymbolGOFF>(Sym);
354352 if (Symbol.hasLDAttributes ()) {
353+ Symbol.setIndex (++Ordinal);
355354 defineLabel (Symbol);
356355 }
357356 }
0 commit comments