llvm.org GIT mirror llvm / 30deafc
Put each personality function in a section. This fixes the gnu ld warning: error in foo.o; no .eh_frame_hdr table will be created. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@129635 91177308-0d34-0410-b5e6-96231b3b80d8 Rafael Espindola 9 years ago
5 changed file(s) with 57 addition(s) and 8 deletion(s). Raw diff Collapse all Expand all
5757 virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
5858
5959 virtual const MCSection *getEHFrameSection() const;
60 virtual MCSymbol *getPersonalityPICSymbol(StringRef Name) const;
61
62 virtual void emitPersonalityValue(MCStreamer &Streamer,
63 const TargetMachine &TM,
64 const MCSymbol *Sym) const;
6065
6166 const MCSection *getDataRelSection() const { return DataRelSection; }
6267
139139 const MCSection *getStaticDtorSection() const { return StaticDtorSection; }
140140 const MCSection *getLSDASection() const { return LSDASection; }
141141 virtual const MCSection *getEHFrameSection() const = 0;
142 virtual MCSymbol *getPersonalityPICSymbol(StringRef Name) const;
143 virtual void emitPersonalityValue(MCStreamer &Streamer,
144 const TargetMachine &TM,
145 const MCSymbol *Sym) const;
142146 const MCSection *getDwarfAbbrevSection() const { return DwarfAbbrevSection; }
143147 const MCSection *getDwarfInfoSection() const { return DwarfInfoSection; }
144148 const MCSection *getDwarfLineSection() const { return DwarfLineSection; }
5757 const TargetLoweringObjectFile &TLOF = Asm->getObjFileLowering();
5858 unsigned PerEncoding = TLOF.getPersonalityEncoding();
5959
60 // Begin eh frame section.
61 Asm->OutStreamer.SwitchSection(TLOF.getEHFrameSection());
62
6360 if ((PerEncoding & 0x70) != dwarf::DW_EH_PE_pcrel)
6461 return;
6562
6663 // Emit references to all used personality functions
6764 const std::vector &Personalities = MMI->getPersonalities();
6865 for (size_t i = 0, e = Personalities.size(); i != e; ++i) {
69 Asm->OutStreamer.EmitLabel(Asm->GetTempSymbol("personality", i));
7066 const MCSymbol *Sym = Asm->Mang->getSymbol(Personalities[i]);
71 unsigned Size = Asm->TM.getTargetData()->getPointerSize();
72 Asm->OutStreamer.EmitSymbolValue(Sym, Size);
67 TLOF.emitPersonalityValue(Asm->OutStreamer, Asm->TM, Sym);
7368 }
7469 }
7570
122117 break;
123118 }
124119 case dwarf::DW_EH_PE_pcrel: {
125 Sym = Asm->GetTempSymbol("personality",
126 MMI->getPersonalityIndex());
120 MCContext &Context = Asm->OutStreamer.getContext();
121 Sym = TLOF.getPersonalityPICSymbol(Per->getName());
127122 break;
128123 }
129124 }
2222 #include "llvm/MC/MCSectionMachO.h"
2323 #include "llvm/MC/MCSectionELF.h"
2424 #include "llvm/MC/MCSectionCOFF.h"
25 #include "llvm/MC/MCStreamer.h"
2526 #include "llvm/MC/MCSymbol.h"
2627 #include "llvm/Target/Mangler.h"
2728 #include "llvm/Target/TargetData.h"
175176 SectionKind::getDataRel());
176177 }
177178
179 MCSymbol *
180 TargetLoweringObjectFileELF::getPersonalityPICSymbol(StringRef Name) const {
181 Twine FullName = StringRef("DW.ref.") + Name;
182 return getContext().GetOrCreateSymbol(FullName);
183 }
184
185 void TargetLoweringObjectFileELF::emitPersonalityValue(MCStreamer &Streamer,
186 const TargetMachine &TM,
187 const MCSymbol *Sym) const {
188 MCSymbol *Label = getPersonalityPICSymbol(Sym->getName());
189 Streamer.EmitSymbolAttribute(Label, MCSA_Hidden);
190 Streamer.EmitSymbolAttribute(Label, MCSA_Weak);
191 Twine SectionName = StringRef(".data.") + Label->getName();
192 SmallString<64> NameData;
193 SectionName.toVector(NameData);
194 unsigned Flags = ELF::SHF_ALLOC | ELF::SHF_WRITE | ELF::SHF_GROUP;
195 const MCSection *Sec = getContext().getELFSection(NameData,
196 ELF::SHT_PROGBITS,
197 Flags,
198 SectionKind::getDataRel(),
199 0, Label->getName());
200 Streamer.SwitchSection(Sec);
201 Streamer.EmitValueToAlignment(8);
202 Streamer.EmitSymbolAttribute(Label, MCSA_ELF_TypeObject);
203 const MCExpr *E = MCConstantExpr::Create(8, getContext());
204 Streamer.EmitELFSize(Label, E);
205 Streamer.EmitLabel(Label);
206
207 unsigned Size = TM.getTargetData()->getPointerSize();
208 Streamer.EmitSymbolValue(Sym, Size);
209 }
210
178211 static SectionKind
179212 getELFKindForNamedSection(StringRef Name, SectionKind K) {
180213 // FIXME: Why is this here? Codegen is should not be in the business
118118
119119 return false;
120120 }
121
122 MCSymbol *
123 TargetLoweringObjectFile::getPersonalityPICSymbol(StringRef Name) const {
124 assert(0 && "Not Available in this format.");
125 }
126
127 void TargetLoweringObjectFile::emitPersonalityValue(MCStreamer &Streamer,
128 const TargetMachine &TM,
129 const MCSymbol *Sym) const {
130 assert(0 && "Not Available in this format.");
131 }
132
121133
122134 /// getKindForGlobal - This is a top-level target-independent classifier for
123135 /// a global variable. Given an global variable and information from TM, it