[llvm-commits] [Review request] Tweak section names of linkonce on PECOFF

NAKAMURA Takumi geek4civic at gmail.com
Sun Oct 10 08:58:31 PDT 2010


Anton,

It seems GNU ld relies on section's name to integrate/discard sections.
Please take a look into this.

W/O this, linking against gcc/libstdc++ must fail.

It might be essential to build clang++/mingw bootstrap stage2, I think.

ps. thank you to previous patch. I saw warnings reduced on linking.


...Takumi
-------------- next part --------------
commit 31f145988ce25c5e4fd1446f0ddf0e9390c38f9c
Author: NAKAMURA Takumi <geek4civic at gmail.com>
Date:   Tue Sep 28 00:22:54 2010

    lib/CodeGen/TargetLoweringObjectFileImpl.cpp: Tweak to emit ".section${name}" instead of ".section$linkonce_{name}".
    
    It seems GNU ld relies on section names.

diff --git a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
index 164ee37..890d6e7 100644
--- a/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
+++ b/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
@@ -981,12 +981,12 @@ getExplicitSectionGlobal(const GlobalValue *GV, SectionKind Kind,
 
 static const char *getCOFFSectionPrefixForUniqueGlobal(SectionKind Kind) {
   if (Kind.isText())
-    return ".text$linkonce";
+    return ".text$";
   if (Kind.isBSS ())
-    return ".bss$linkonce";
+    return ".bss$";
   if (Kind.isWriteable())
-    return ".data$linkonce";
-  return ".rdata$linkonce";
+    return ".data$";
+  return ".rdata$";
 }
 
 
@@ -1001,7 +1001,7 @@ SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
     const char *Prefix = getCOFFSectionPrefixForUniqueGlobal(Kind);
     SmallString<128> Name(Prefix, Prefix+strlen(Prefix));
     MCSymbol *Sym = Mang->getSymbol(GV);
-    Name.append(Sym->getName().begin(), Sym->getName().end());
+    Name.append(Sym->getName().begin() + 1, Sym->getName().end());
 
     unsigned Characteristics = getCOFFSectionFlags(Kind);
 


More information about the llvm-commits mailing list