gcc often inserts it's own names for sections (e.g.
authorAnton Korobeynikov <asl@math.spbu.ru>
Sat, 6 Jan 2007 18:24:26 +0000 (18:24 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Sat, 6 Jan 2007 18:24:26 +0000 (18:24 +0000)
gnu.linkonce.t.FunctionName). Convert them to "normal" LLVM names,
otherwise linker won't be able to merge them.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32958 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/X86/X86ATTAsmPrinter.cpp

index e3448928416e5b38d3a1e6d87f82f83de21e7541..d71bc784df5199fa860dc2f75b9a4438f7cacae6 100755 (executable)
@@ -80,8 +80,13 @@ bool X86ATTAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
 
   X86SharedAsmPrinter::decorateName(CurrentFnName, F);
 
-  SwitchToTextSection(getSectionForFunction(*F).c_str(), F);
-  
+  // Change GNU linkonce to LLVM linkonce name
+  if (F->hasSection() &&
+      (F->getSection().find(".gnu.linkonce.t") != std::string::npos))
+    SwitchToTextSection(getSectionForFunction(*F).c_str(), NULL);
+  else
+    SwitchToTextSection(getSectionForFunction(*F).c_str(), F);
+    
   switch (F->getLinkage()) {
   default: assert(0 && "Unknown linkage type!");
   case Function::InternalLinkage:  // Symbols default to internal.