[llvm] [GOFF] Set reference to ADA (PR #179734)

Kai Nacke via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 5 07:12:23 PST 2026


================
@@ -55,16 +55,20 @@ void MCGOFFStreamer::changeSection(MCSection *Section, uint32_t Subsection) {
   }
 }
 
-void MCGOFFStreamer::emitLabel(MCSymbol *Symbol, SMLoc Loc) {
+void MCGOFFStreamer::emitLabel(MCSymbol *Sym, SMLoc Loc) {
   MCSectionGOFF *Section =
       static_cast<MCSectionGOFF *>(getCurrentSectionOnly());
+  MCSymbolGOFF *Symbol = static_cast<MCSymbolGOFF *>(Sym);
   if (Section->isPR()) {
     if (Section->getBeginSymbol() == nullptr)
       Section->setBeginSymbol(Symbol);
     else
       getContext().reportError(
           Loc, "only one symbol can be defined in a PR section.");
   }
+  if (Section->getBeginSymbol() && Symbol->getCodeData() == GOFF::ESD_EXE_CODE)
+    Symbol->setADA(
+        static_cast<MCSymbolGOFF *>(Section->getBeginSymbol())->getADA());
----------------
redstar wrote:

A section does not always have a begin symbol. E.g. there are no references to the IDRL section, so no begin symbol is set: https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp#L1310
Only the begin symbol of the text section has the ADA link set, because this is only relevant for code. All other begin symbols have a NULL ADA.
I put the check for ADA being NULL into setADA(), mainly because then the link could also be cleared. However, it does not really matter since here is the only caller which could pass in a NULL for link, so the check could also be here.

https://github.com/llvm/llvm-project/pull/179734


More information about the llvm-commits mailing list