When outputing a non-lazy pointer for a stub, we may need to fill in the value
authorBill Wendling <isanbard@gmail.com>
Thu, 11 Mar 2010 01:18:13 +0000 (01:18 +0000)
committerBill Wendling <isanbard@gmail.com>
Thu, 11 Mar 2010 01:18:13 +0000 (01:18 +0000)
for the NLP because the object it's pointing to may be internal to the file.

This seems counter-intuitive, but bear with me. When we place the LSDA into the
TEXT section, the type info pointers need to be indirect and pc-rel. We
accomplish this by using NLPs. However, sometimes the types are local to the
file. GCC gets around this by not using a NLP in this case, but a "regular"
indirection like this:

GCC_except_tbl:
  .long Lfoo-.

__ZTIA:  @ This is local
  ...

Lfoo:
  .long __ZTIA

LLVM prefers NLPs on Darwin. In fact, it's more optimal for load performance to
use them.

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

lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp

index a2aeca4e0665cc4dd5081635ecde989081c0e1d6..42b8820c5007a1cd65c5697cb14bed652ddfa202 100644 (file)
@@ -1137,15 +1137,16 @@ void ARMAsmPrinter::EmitEndOfAsmFile(Module &M) {
         // L_foo$stub:
         OutStreamer.EmitLabel(Stubs[i].first);
         //   .indirect_symbol _foo
-        MCSymbol *MCSym = Stubs[i].second.getPointer();
-        OutStreamer.EmitSymbolAttribute(MCSymMCSA_IndirectSymbol);
+        MachineModuleInfoImpl::StubValueTy &MCSym = Stubs[i].second;
+        OutStreamer.EmitSymbolAttribute(MCSym.getPointer(),MCSA_IndirectSymbol);
 
-        if (MCSym->isUndefined())
+        if (MCSym.getInt())
           // External to current translation unit.
           OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/);
         else
           // Internal to current translation unit.
-          OutStreamer.EmitValue(MCSymbolRefExpr::Create(MCSym, OutContext),
+          OutStreamer.EmitValue(MCSymbolRefExpr::Create(MCSym.getPointer(),
+                                                        OutContext),
                                 4/*size*/, 0/*addrspace*/);
       }