llvm.org GIT mirror llvm / 293d592
It turned out that we failed to emit proper symbol stubs on non-x86/darwin for ages (we emitted a reference to a stub, but no stub was emitted). The code inside x86-32/macho target objfile lowering should actually be the generic one - move it there. This (I really, really hope) should fix EH issues on ppc/darwin and arm/darwin. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@96755 91177308-0d34-0410-b5e6-96231b3b80d8 Anton Korobeynikov 10 years ago
5 changed file(s) with 35 addition(s) and 84 deletion(s). Raw diff Collapse all Expand all
170170 virtual const MCExpr *
171171 getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
172172 MachineModuleInfo *MMI, unsigned Encoding) const;
173
174 virtual unsigned getPersonalityEncoding() const;
175 virtual unsigned getLSDAEncoding() const;
176 virtual unsigned getFDEEncoding() const;
177 virtual unsigned getTTypeEncoding() const;
173178 };
174179
175180
3232 #include "llvm/ADT/SmallString.h"
3333 #include "llvm/ADT/StringExtras.h"
3434 using namespace llvm;
35 using namespace dwarf;
3536
3637 //===----------------------------------------------------------------------===//
3738 // ELF
737738 MachineModuleInfo *MMI, unsigned Encoding) const {
738739 // The mach-o version of this method defaults to returning a stub reference.
739740
740 if (Encoding & dwarf::DW_EH_PE_indirect) {
741 if (Encoding & DW_EH_PE_indirect) {
742 MachineModuleInfoMachO &MachOMMI =
743 MMI->getObjFileInfo();
744
741745 SmallString<128> Name;
742746 Mang->getNameWithPrefix(Name, GV, true);
743747 Name += "$non_lazy_ptr";
748
749 // Add information about the stub reference to MachOMMI so that the stub
750 // gets emitted by the asmprinter.
744751 MCSymbol *Sym = getContext().GetOrCreateSymbol(Name.str());
752 MCSymbol *&StubSym = MachOMMI.getGVStubEntry(Sym);
753 if (StubSym == 0) {
754 Name.clear();
755 Mang->getNameWithPrefix(Name, GV, false);
756 StubSym = getContext().GetOrCreateSymbol(Name.str());
757 }
745758
746759 return TargetLoweringObjectFile::
747760 getSymbolForDwarfReference(Sym, MMI,
752765 getSymbolForDwarfGlobalReference(GV, Mang, MMI, Encoding);
753766 }
754767
768 unsigned TargetLoweringObjectFileMachO::getPersonalityEncoding() const {
769 return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4;
770 }
771
772 unsigned TargetLoweringObjectFileMachO::getLSDAEncoding() const {
773 return DW_EH_PE_pcrel;
774 }
775
776 unsigned TargetLoweringObjectFileMachO::getFDEEncoding() const {
777 return DW_EH_PE_pcrel;
778 }
779
780 unsigned TargetLoweringObjectFileMachO::getTTypeEncoding() const {
781 return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4;
782 }
755783
756784 //===----------------------------------------------------------------------===//
757785 // COFF
7272 case X86Subtarget::isDarwin:
7373 if (TM.getSubtarget().is64Bit())
7474 return new X8664_MachoTargetObjectFile();
75 return new X8632_MachoTargetObjectFile();
75 return new TargetLoweringObjectFileMachO();
7676 case X86Subtarget::isELF:
7777 if (TM.getSubtarget().is64Bit())
7878 return new X8664_ELFTargetObjectFile(TM);
1616 #include "llvm/Support/Dwarf.h"
1717 using namespace llvm;
1818 using namespace dwarf;
19
20 const MCExpr *X8632_MachoTargetObjectFile::
21 getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
22 MachineModuleInfo *MMI, unsigned Encoding) const {
23 // The mach-o version of this method defaults to returning a stub reference.
24
25 if (Encoding & DW_EH_PE_indirect) {
26 MachineModuleInfoMachO &MachOMMI =
27 MMI->getObjFileInfo();
28
29 SmallString<128> Name;
30 Mang->getNameWithPrefix(Name, GV, true);
31 Name += "$non_lazy_ptr";
32
33 // Add information about the stub reference to MachOMMI so that the stub
34 // gets emitted by the asmprinter.
35 MCSymbol *Sym = getContext().GetOrCreateSymbol(Name.str());
36 MCSymbol *&StubSym = MachOMMI.getGVStubEntry(Sym);
37 if (StubSym == 0) {
38 Name.clear();
39 Mang->getNameWithPrefix(Name, GV, false);
40 StubSym = getContext().GetOrCreateSymbol(Name.str());
41 }
42
43 return TargetLoweringObjectFile::
44 getSymbolForDwarfReference(Sym, MMI,
45 Encoding & ~dwarf::DW_EH_PE_indirect);
46 }
47
48 return TargetLoweringObjectFileMachO::
49 getSymbolForDwarfGlobalReference(GV, Mang, MMI, Encoding);
50 }
5119
5220 const MCExpr *X8664_MachoTargetObjectFile::
5321 getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
147115
148116 return DW_EH_PE_absptr;
149117 }
150
151 unsigned X8632_MachoTargetObjectFile::getPersonalityEncoding() const {
152 return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4;
153 }
154
155 unsigned X8632_MachoTargetObjectFile::getLSDAEncoding() const {
156 return DW_EH_PE_pcrel;
157 }
158
159 unsigned X8632_MachoTargetObjectFile::getFDEEncoding() const {
160 return DW_EH_PE_pcrel;
161 }
162
163 unsigned X8632_MachoTargetObjectFile::getTTypeEncoding() const {
164 return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4;
165 }
166
167 unsigned X8664_MachoTargetObjectFile::getPersonalityEncoding() const {
168 return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4;
169 }
170
171 unsigned X8664_MachoTargetObjectFile::getLSDAEncoding() const {
172 return DW_EH_PE_pcrel;
173 }
174
175 unsigned X8664_MachoTargetObjectFile::getFDEEncoding() const {
176 return DW_EH_PE_pcrel;
177 }
178
179 unsigned X8664_MachoTargetObjectFile::getTTypeEncoding() const {
180 return DW_EH_PE_indirect | DW_EH_PE_pcrel | DW_EH_PE_sdata4;
181 }
1616 namespace llvm {
1717 class X86TargetMachine;
1818
19 /// X8632_MachoTargetObjectFile - This TLOF implementation is used for
20 /// Darwin/x86-32.
21 class X8632_MachoTargetObjectFile : public TargetLoweringObjectFileMachO {
22 public:
23
24 virtual const MCExpr *
25 getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
26 MachineModuleInfo *MMI, unsigned Encoding) const;
27 virtual unsigned getPersonalityEncoding() const;
28 virtual unsigned getLSDAEncoding() const;
29 virtual unsigned getFDEEncoding() const;
30 virtual unsigned getTTypeEncoding() const;
31 };
32
3319 /// X8664_MachoTargetObjectFile - This TLOF implementation is used for
3420 /// Darwin/x86-64.
3521 class X8664_MachoTargetObjectFile : public TargetLoweringObjectFileMachO {
3824 virtual const MCExpr *
3925 getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
4026 MachineModuleInfo *MMI, unsigned Encoding) const;
41 virtual unsigned getPersonalityEncoding() const;
42 virtual unsigned getLSDAEncoding() const;
43 virtual unsigned getFDEEncoding() const;
44 virtual unsigned getTTypeEncoding() const;
4527 };
4628
4729 class X8632_ELFTargetObjectFile : public TargetLoweringObjectFileELF {