[clang] [llvm] [Clang] -fseparate-named-sections option (PR #91028)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat May 4 15:16:00 PDT 2024


================
@@ -733,16 +733,22 @@ calcUniqueIDUpdateFlagsAndSize(const GlobalObject *GO, StringRef SectionName,
       Ctx.isELFGenericMergeableSection(SectionName);
   // If this is the first ocurrence of this section name, treat it as the
   // generic section
-  if (!SymbolMergeable && !SeenSectionNameBefore)
-    return MCContext::GenericSectionID;
+  if (!SymbolMergeable && !SeenSectionNameBefore) {
+    if (TM.getSeparateNamedSections())
+      return NextUniqueID++;
+    else
+      return MCContext::GenericSectionID;
+  }
 
   // Symbols must be placed into sections with compatible entry sizes. Generate
   // unique sections for symbols that have not been assigned to compatible
   // sections.
   const auto PreviousID =
       Ctx.getELFUniqueIDForEntsize(SectionName, Flags, EntrySize);
-  if (PreviousID)
+  if (PreviousID && (!TM.getSeparateNamedSections() ||
+                     *PreviousID == MCContext::GenericSectionID)) {
     return *PreviousID;
----------------
MaskRay wrote:

drop braces for one-line single statement

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


More information about the llvm-commits mailing list