[llvm-branch-commits] [llvm] [GOFF] Add writing of section symbols (PR #133799)

Kai Nacke via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Apr 10 07:23:00 PDT 2025


================
@@ -2759,6 +2762,29 @@ MCSection *TargetLoweringObjectFileXCOFF::getSectionForLSDA(
 //===----------------------------------------------------------------------===//
 TargetLoweringObjectFileGOFF::TargetLoweringObjectFileGOFF() = default;
 
+void TargetLoweringObjectFileGOFF::getModuleMetadata(Module &M) {
+  // Construct the default names for the root SD and the ADA PR symbol.
+  StringRef FileName = sys::path::stem(M.getSourceFileName());
+  if (FileName.size() > 1 && FileName.starts_with('<') &&
+      FileName.ends_with('>'))
+    FileName = FileName.substr(1, FileName.size() - 2);
+  DefaultRootSDName = Twine(FileName).concat("#C").str();
----------------
redstar wrote:

Using a name and setting the binding scope to "section scope" is similar to using " " as name and leaving the binding scope unspecified.
The XLC and Open XL compilers provide a command line option to change this name (XLC: `-qcsect`, `-qnocsect`; Open XL: `-mcsect`, `-mnocsect`). The Open XL compiler defaults to the variant coded here but that can be changed to having a name with binding scope unspecified (`-mcsect=a`) or set to space (`-mnocsect`).
Using `-mcsect=a` results in exactly the problem you describe.
The compiler option will be added later to clang, along with the required code here.

The front end (aka clang) provides this value in the `source_filename` property. All strings in LLVM/clang are in UTF-8 so there is no other choice. The same problem arises for symbols derived from function names etc.

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


More information about the llvm-branch-commits mailing list