diff options
author | Evan Cheng <evan.cheng@apple.com> | 2008-12-05 01:06:39 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2008-12-05 01:06:39 +0000 |
commit | ae94e594164b193236002516970aeec4c4574768 (patch) | |
tree | 00f4a5e3d57725f8b01a1ca106e61cba657d8ded /lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp | |
parent | cd730fa3377ba9f019c810c3181390960b85e831 (diff) | |
download | external_llvm-ae94e594164b193236002516970aeec4c4574768.zip external_llvm-ae94e594164b193236002516970aeec4c4574768.tar.gz external_llvm-ae94e594164b193236002516970aeec4c4574768.tar.bz2 |
Re-did 60519. It turns out Darwin's handling of hidden visibility symbols are a bit more complicate than I expected. Both declarations and weak definitions still need a stub indirection. However, the stubs are in data section and they contain the addresses of the actual symbols.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60571 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp')
-rw-r--r-- | lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp index 66319c3..76b1ddc 100644 --- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp +++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp @@ -391,6 +391,14 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo, FnStubs.insert(Name); printSuffixedName(Name, "$stub"); } + } else if (GV->hasHiddenVisibility()) { + if (!GV->isDeclaration() && !GV->hasCommonLinkage()) + // Definition is not definitely in the current translation unit. + O << Name; + else { + HiddenGVStubs.insert(Name); + printSuffixedName(Name, "$non_lazy_ptr"); + } } else { GVStubs.insert(Name); printSuffixedName(Name, "$non_lazy_ptr"); @@ -875,6 +883,15 @@ void X86ATTAsmPrinter::printGVStub(const char *GV, const char *Prefix) { O << GV << "\n\t.long\t0\n"; } +/// printHiddenGVStub - Print stub for a hidden global value. +/// +void X86ATTAsmPrinter::printHiddenGVStub(const char *GV, const char *Prefix) { + EmitAlignment(2); + printSuffixedName(GV, "$non_lazy_ptr", Prefix); + if (Prefix) O << Prefix; + O << ":\n" << TAI->getData32bitsDirective() << GV << '\n'; +} + bool X86ATTAsmPrinter::doFinalization(Module &M) { // Print out module-level global variables here. @@ -908,9 +925,8 @@ bool X86ATTAsmPrinter::doFinalization(Module &M) { SwitchToDataSection(""); // Output stubs for dynamically-linked functions - unsigned j = 1; for (StringSet<>::iterator i = FnStubs.begin(), e = FnStubs.end(); - i != e; ++i, ++j) { + i != e; ++i) { SwitchToDataSection("\t.section __IMPORT,__jump_table,symbol_stubs," "self_modifying_code+pure_instructions,5", 0); const char *p = i->getKeyData(); @@ -949,6 +965,13 @@ bool X86ATTAsmPrinter::doFinalization(Module &M) { i != e; ++i) printGVStub(i->getKeyData()); + if (!HiddenGVStubs.empty()) { + SwitchToSection(TAI->getDataSection()); + for (StringSet<>::iterator i = HiddenGVStubs.begin(), e = HiddenGVStubs.end(); + i != e; ++i) + printHiddenGVStub(i->getKeyData()); + } + // Emit final debug information. DW.EndModule(); |