reapply r95206, this time actually delete the code I'm replacing in the third stub case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95209 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2010-02-03 06:42:38 +00:00
parent 8427d2b0c6
commit beb42691b1

View File

@ -27,6 +27,7 @@
#include "llvm/Type.h" #include "llvm/Type.h"
#include "llvm/Assembly/Writer.h" #include "llvm/Assembly/Writer.h"
#include "llvm/MC/MCContext.h" #include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCSectionMachO.h" #include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCStreamer.h" #include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbol.h"
@ -502,14 +503,17 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
OutStreamer.SwitchSection(TheSection); OutStreamer.SwitchSection(TheSection);
for (unsigned i = 0, e = Stubs.size(); i != e; ++i) { for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
O << *Stubs[i].first << ":\n"; // L_foo$stub:
// Get the MCSymbol without the $stub suffix. OutStreamer.EmitLabel(Stubs[i].first);
O << "\t.indirect_symbol " << *Stubs[i].second; // .indirect_symbol _foo
O << "\n\thlt ; hlt ; hlt ; hlt ; hlt\n"; OutStreamer.EmitSymbolAttribute(Stubs[i].second, MCSA_IndirectSymbol);
// hlt; hlt; hlt; hlt; hlt hlt = 0xf4 = -12.
const char HltInsts[] = { -12, -12, -12, -12, -12 };
OutStreamer.EmitBytes(StringRef(HltInsts, 5), 0/*addrspace*/);
} }
O << '\n';
Stubs.clear(); Stubs.clear();
OutStreamer.AddBlankLine();
} }
// Output stubs for external and common global variables. // Output stubs for external and common global variables.
@ -522,10 +526,15 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
OutStreamer.SwitchSection(TheSection); OutStreamer.SwitchSection(TheSection);
for (unsigned i = 0, e = Stubs.size(); i != e; ++i) { for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
O << *Stubs[i].first << ":\n\t.indirect_symbol " << *Stubs[i].second; // L_foo$non_lazy_ptr:
O << "\n\t.long\t0\n"; OutStreamer.EmitLabel(Stubs[i].first);
// .indirect_symbol _foo
OutStreamer.EmitSymbolAttribute(Stubs[i].second, MCSA_IndirectSymbol);
// .long 0
OutStreamer.EmitIntValue(0, 4/*size*/, 0/*addrspace*/);
} }
Stubs.clear(); Stubs.clear();
OutStreamer.AddBlankLine();
} }
Stubs = MMIMacho.GetHiddenGVStubList(); Stubs = MMIMacho.GetHiddenGVStubList();
@ -534,10 +543,15 @@ void X86AsmPrinter::EmitEndOfAsmFile(Module &M) {
EmitAlignment(2); EmitAlignment(2);
for (unsigned i = 0, e = Stubs.size(); i != e; ++i) { for (unsigned i = 0, e = Stubs.size(); i != e; ++i) {
O << *Stubs[i].first << ":\n" << MAI->getData32bitsDirective(); // L_foo$non_lazy_ptr:
O << *Stubs[i].second << '\n'; OutStreamer.EmitLabel(Stubs[i].first);
// .long _foo
OutStreamer.EmitValue(MCSymbolRefExpr::Create(Stubs[i].second,
OutContext),
4/*size*/, 0/*addrspace*/);
} }
Stubs.clear(); Stubs.clear();
OutStreamer.AddBlankLine();
} }
// Funny Darwin hack: This flag tells the linker that no global symbols // Funny Darwin hack: This flag tells the linker that no global symbols