[llvm] [SystemZ][z/OS] Emit CELQMAIN for a module defining main (PR #226710)
MMS IT GmbH via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 29 12:48:04 PDT 2026
================
@@ -289,6 +294,53 @@ void SystemZXPLINKAsmPrinter::emitEndOfAsmFile(Module &M) {
}
}
+// Emit CELQMAIN in RENT format (see z/OS Language Environment Vendor
+// Interfaces, "Program initialization and termination for AMODE 64
+// applications"):
+// +0 X'04000001'
+// +8 AD(main entry point)
+// +10 AD(CELQINPL)
+// +18 A(0) / Q(environment); emitted as 8 byte R-con to main, which the
+// binder resolves to the offset of the ADA of main (fits into 4 bytes)
+// followed by a reference to the bootstrap routine CELQBST. CELQSTRT only has
+// a weak reference to CELQBST, so without it autocall would not include it.
+void SystemZXPLINKAsmPrinter::emitCELQMAIN(const Function &MainFn) {
+ MCSymbol *MainSym = getSymbol(&MainFn);
+ auto ExternalOSSymbol = [&](StringRef Name) {
+ MCSymbol *Sym = OutContext.getOrCreateSymbol(Name);
+ OutStreamer->emitSymbolAttribute(Sym, MCSA_OSLinkage);
+ OutStreamer->emitSymbolAttribute(Sym, MCSA_Global);
+ return Sym;
+ };
+ MCSymbol *CELQINPL = ExternalOSSymbol("CELQINPL");
+ MCSymbol *CELQBST = ExternalOSSymbol("CELQBST");
+
+ OutStreamer->pushSection();
+ OutStreamer->switchSection(getObjFileLowering().getTextSection());
----------------
mms-it-ch wrote:
Moved the emission of CELQMAIN to emitStartOfAsmFile(), next to the PPA2, while the text section is still open (5a538af43). Added zos-celqmain-debug.ll with debug info and -generate-arange-section, which hit the "Section already ended" assertion before.
_🤖 Addressed by [Claude Code](https://claude.com/claude-code)_
https://github.com/llvm/llvm-project/pull/226710
More information about the llvm-commits
mailing list