[llvm-commits] [llvm] r151433 - in /llvm/trunk: lib/Target/PowerPC/PPCAsmPrinter.cpp test/CodeGen/PowerPC/ppc64-linux-func-size.ll

Hal Finkel hfinkel at anl.gov
Fri Feb 24 19:40:11 PST 2012


Author: hfinkel
Date: Fri Feb 24 21:40:11 2012
New Revision: 151433

URL: http://llvm.org/viewvc/llvm-project?rev=151433&view=rev
Log:
Revert r151278, breaks static linking.

Reverting this because it breaks static linking on ppc64. Specifically, it may be linkonce_odr functions that are the problem.
With this patch, if you link statically, calls to some functions end up calling their descriptor addresses instead
of calling to their entry points. This causes the execution to fail with SIGILL (b/c the descriptor address just
has some pointers, not code).

Modified:
    llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp
    llvm/trunk/test/CodeGen/PowerPC/ppc64-linux-func-size.ll

Modified: llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp?rev=151433&r1=151432&r2=151433&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCAsmPrinter.cpp Fri Feb 24 21:40:11 2012
@@ -39,7 +39,6 @@
 #include "llvm/MC/MCSectionMachO.h"
 #include "llvm/MC/MCStreamer.h"
 #include "llvm/MC/MCSymbol.h"
-#include "llvm/MC/MCSectionELF.h"
 #include "llvm/Target/Mangler.h"
 #include "llvm/Target/TargetRegisterInfo.h"
 #include "llvm/Target/TargetInstrInfo.h"
@@ -50,7 +49,6 @@
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/ELF.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/SmallString.h"
 #include "InstPrinter/PPCInstPrinter.h"
@@ -393,19 +391,13 @@
     return AsmPrinter::EmitFunctionEntryLabel();
     
   // Emit an official procedure descriptor.
-  const MCSection *Current = OutStreamer.getCurrentSection();
-  const MCSectionELF *Section = OutStreamer.getContext().getELFSection(".opd",
-      ELF::SHT_PROGBITS, 0, SectionKind::getReadOnly());
-  OutStreamer.SwitchSection(Section);
+  // FIXME 64-bit SVR4: Use MCSection here!
+  OutStreamer.EmitRawText(StringRef("\t.section\t\".opd\",\"aw\""));
+  OutStreamer.EmitRawText(StringRef("\t.align 3"));
   OutStreamer.EmitLabel(CurrentFnSym);
-  MCSymbol *Symbol1 = 
-    OutContext.GetOrCreateSymbol(".L." + Twine(CurrentFnSym->getName()));
-  MCSymbol *Symbol2 = OutContext.GetOrCreateSymbol(StringRef(".TOC. at tocbase"));
-  OutStreamer.EmitValue(MCSymbolRefExpr::Create(Symbol1, OutContext),
-                        Subtarget.isPPC64() ? 8 : 4/*size*/, 0/*addrspace*/);
-  OutStreamer.EmitValue(MCSymbolRefExpr::Create(Symbol2, OutContext),
-                        Subtarget.isPPC64() ? 8 : 4/*size*/, 0/*addrspace*/);
-  OutStreamer.SwitchSection(Current);
+  OutStreamer.EmitRawText("\t.quad .L." + Twine(CurrentFnSym->getName()) +
+                          ",.TOC. at tocbase");
+  OutStreamer.EmitRawText(StringRef("\t.previous"));
 
   MCSymbol *RealFnSym = OutContext.GetOrCreateSymbol(
                           ".L." + Twine(CurrentFnSym->getName()));

Modified: llvm/trunk/test/CodeGen/PowerPC/ppc64-linux-func-size.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/ppc64-linux-func-size.ll?rev=151433&r1=151432&r2=151433&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/ppc64-linux-func-size.ll (original)
+++ llvm/trunk/test/CodeGen/PowerPC/ppc64-linux-func-size.ll Fri Feb 24 21:40:11 2012
@@ -1,9 +1,8 @@
 ; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=g5 | FileCheck %s
 
 ; CHECK: test1:
-; CHECK-NEXT:	.quad .L.test1
-; CHECK-NEXT:	.quad .TOC. at tocbase
-; CHECK-NEXT:	.text
+; CHECK-NEXT:  .quad .L.test1,.TOC. at tocbase
+; CHECK-NEXT:  .previous
 ; CHECK-NEXT: .L.test1:
 
 define i32 @test1(i32 %a) nounwind {





More information about the llvm-commits mailing list