diff options
author | Chris Lattner <sabre@nondot.org> | 2009-08-03 22:18:15 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-08-03 22:18:15 +0000 |
commit | f61159b574155b056dbd5d6d44f47f753d424056 (patch) | |
tree | 50fc5676734fb1daa3107f073e2857b15544b9da | |
parent | 865aaf00ad5f3792e25e29bb4514e1cc70964bf3 (diff) |
convert macho stub emission to use SwitchToSection instead of
textual sections.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78007 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp | 84 |
1 files changed, 50 insertions, 34 deletions
diff --git a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp index eb3984674d..cb7388f749 100644 --- a/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp +++ b/lib/Target/ARM/AsmPrinter/ARMAsmPrinter.cpp @@ -1269,49 +1269,65 @@ void ARMAsmPrinter::PrintGlobalVariable(const GlobalVariable* GVar) { bool ARMAsmPrinter::doFinalization(Module &M) { if (Subtarget->isTargetDarwin()) { - SwitchToDataSection(""); - + // All darwin targets use mach-o. + TargetLoweringObjectFileMachO &TLOFMacho = + static_cast<TargetLoweringObjectFileMachO &>(getObjFileLowering()); + O << '\n'; - // Output stubs for dynamically-linked functions - for (StringMap<FnStubInfo>::iterator I = FnStubs.begin(), E = FnStubs.end(); - I != E; ++I) { - const FnStubInfo &Info = I->second; + + if (!FnStubs.empty()) { + const MCSection *StubSection; if (TM.getRelocationModel() == Reloc::PIC_) - SwitchToTextSection(".section __TEXT,__picsymbolstub4,symbol_stubs," - "none,16", 0); + StubSection = TLOFMacho.getMachOSection(".section __TEXT,__picsymbolstu" + "b4,symbol_stubs,none,16", true, + SectionKind::getText()); else - SwitchToTextSection(".section __TEXT,__symbol_stub4,symbol_stubs," - "none,12", 0); + StubSection = TLOFMacho.getMachOSection(".section __TEXT,__symbol_stub4" + ",symbol_stubs,none,12", true, + SectionKind::getText()); - EmitAlignment(2); - O << "\t.code\t32\n"; - - O << Info.Stub << ":\n"; - O << "\t.indirect_symbol " << I->getKeyData() << '\n'; - O << "\tldr ip, " << Info.SLP << '\n'; - if (TM.getRelocationModel() == Reloc::PIC_) { - O << Info.SCV << ":\n"; - O << "\tadd ip, pc, ip\n"; + const MCSection *LazySymbolPointerSection + = TLOFMacho.getMachOSection(".lazy_symbol_pointer", true, + SectionKind::getMetadata()); + + // Output stubs for dynamically-linked functions + for (StringMap<FnStubInfo>::iterator I = FnStubs.begin(), + E = FnStubs.end(); I != E; ++I) { + const FnStubInfo &Info = I->second; + + SwitchToSection(StubSection); + EmitAlignment(2); + O << "\t.code\t32\n"; + + O << Info.Stub << ":\n"; + O << "\t.indirect_symbol " << I->getKeyData() << '\n'; + O << "\tldr ip, " << Info.SLP << '\n'; + if (TM.getRelocationModel() == Reloc::PIC_) { + O << Info.SCV << ":\n"; + O << "\tadd ip, pc, ip\n"; + } + O << "\tldr pc, [ip, #0]\n"; + O << Info.SLP << ":\n"; + O << "\t.long\t" << Info.LazyPtr; + if (TM.getRelocationModel() == Reloc::PIC_) + O << "-(" << Info.SCV << "+8)"; + O << '\n'; + + SwitchToSection(LazySymbolPointerSection); + O << Info.LazyPtr << ":\n"; + O << "\t.indirect_symbol " << I->getKeyData() << "\n"; + O << "\t.long\tdyld_stub_binding_helper\n"; } - O << "\tldr pc, [ip, #0]\n"; - O << Info.SLP << ":\n"; - O << "\t.long\t" << Info.LazyPtr; - if (TM.getRelocationModel() == Reloc::PIC_) - O << "-(" << Info.SCV << "+8)"; O << '\n'; - - SwitchToDataSection(".lazy_symbol_pointer", 0); - O << Info.LazyPtr << ":\n"; - O << "\t.indirect_symbol " << I->getKeyData() << "\n"; - O << "\t.long\tdyld_stub_binding_helper\n"; } - O << '\n'; - + // Output non-lazy-pointers for external and common global variables. if (!GVNonLazyPtrs.empty()) { - SwitchToDataSection("\t.non_lazy_symbol_pointer", 0); - for (StringMap<std::string>::iterator I = GVNonLazyPtrs.begin(), - E = GVNonLazyPtrs.end(); I != E; ++I) { + SwitchToSection(TLOFMacho.getMachOSection(".non_lazy_symbol_pointer", + true, + SectionKind::getMetadata())); + for (StringMap<std::string>::iterator I = GVNonLazyPtrs.begin(), + E = GVNonLazyPtrs.end(); I != E; ++I) { O << I->second << ":\n"; O << "\t.indirect_symbol " << I->getKeyData() << "\n"; O << "\t.long\t0\n"; |