mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 22:24:07 +00:00
Add a parameter to the Win64 EH section getters to get a section with a
suffix (e.g. .xdata$myfunc). The suffix part isn't implemented yet, but I'll get to it in the next patch. Fix up all callers of the affected functions. Make them pass said suffix to the function. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@132205 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -58,8 +58,10 @@ public:
|
|||||||
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
|
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
|
||||||
|
|
||||||
virtual const MCSection *getEHFrameSection() const;
|
virtual const MCSection *getEHFrameSection() const;
|
||||||
virtual const MCSection *getWin64EHFuncTableSection() const { return NULL; }
|
virtual const MCSection *getWin64EHFuncTableSection(StringRef) const {
|
||||||
virtual const MCSection *getWin64EHTableSection() const { return NULL; }
|
return NULL;
|
||||||
|
}
|
||||||
|
virtual const MCSection *getWin64EHTableSection(StringRef) const{return NULL;}
|
||||||
|
|
||||||
virtual void emitPersonalityValue(MCStreamer &Streamer,
|
virtual void emitPersonalityValue(MCStreamer &Streamer,
|
||||||
const TargetMachine &TM,
|
const TargetMachine &TM,
|
||||||
@ -135,8 +137,10 @@ public:
|
|||||||
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
|
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
|
||||||
|
|
||||||
virtual const MCSection *getEHFrameSection() const;
|
virtual const MCSection *getEHFrameSection() const;
|
||||||
virtual const MCSection *getWin64EHFuncTableSection() const { return NULL; }
|
virtual const MCSection *getWin64EHFuncTableSection(StringRef) const {
|
||||||
virtual const MCSection *getWin64EHTableSection() const { return NULL; }
|
return NULL;
|
||||||
|
}
|
||||||
|
virtual const MCSection *getWin64EHTableSection(StringRef) const{return NULL;}
|
||||||
|
|
||||||
virtual const MCSection *
|
virtual const MCSection *
|
||||||
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
|
SelectSectionForGlobal(const GlobalValue *GV, SectionKind Kind,
|
||||||
@ -209,10 +213,12 @@ public:
|
|||||||
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
|
virtual void Initialize(MCContext &Ctx, const TargetMachine &TM);
|
||||||
|
|
||||||
virtual const MCSection *getEHFrameSection() const;
|
virtual const MCSection *getEHFrameSection() const;
|
||||||
virtual const MCSection *getWin64EHFuncTableSection() const {
|
virtual const MCSection *getWin64EHFuncTableSection(StringRef) const {
|
||||||
return PDataSection;
|
return PDataSection;
|
||||||
}
|
}
|
||||||
virtual const MCSection *getWin64EHTableSection() const {return XDataSection;}
|
virtual const MCSection *getWin64EHTableSection(StringRef) const {
|
||||||
|
return XDataSection;
|
||||||
|
}
|
||||||
|
|
||||||
virtual const MCSection *getDrectveSection() const { return DrectveSection; }
|
virtual const MCSection *getDrectveSection() const { return DrectveSection; }
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
class StringRef;
|
||||||
class MCStreamer;
|
class MCStreamer;
|
||||||
class MCSymbol;
|
class MCSymbol;
|
||||||
|
|
||||||
@ -80,6 +81,7 @@ namespace llvm {
|
|||||||
|
|
||||||
class MCWin64EHUnwindEmitter {
|
class MCWin64EHUnwindEmitter {
|
||||||
public:
|
public:
|
||||||
|
static StringRef GetSectionSuffix(const MCSymbol *func);
|
||||||
//
|
//
|
||||||
// This emits the unwind info sections (.pdata and .xdata in PE/COFF).
|
// This emits the unwind info sections (.pdata and .xdata in PE/COFF).
|
||||||
//
|
//
|
||||||
|
@ -63,12 +63,12 @@ public:
|
|||||||
return TLOF->getDwarfFrameSection();
|
return TLOF->getDwarfFrameSection();
|
||||||
}
|
}
|
||||||
|
|
||||||
const MCSection *getWin64EHFuncTableSection() const {
|
const MCSection *getWin64EHFuncTableSection(StringRef Suffix) const {
|
||||||
return TLOF->getWin64EHFuncTableSection();
|
return TLOF->getWin64EHFuncTableSection(Suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
const MCSection *getWin64EHTableSection() const {
|
const MCSection *getWin64EHTableSection(StringRef Suffix) const {
|
||||||
return TLOF->getWin64EHTableSection();
|
return TLOF->getWin64EHTableSection(Suffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned getFDEEncoding(bool CFI) const {
|
unsigned getFDEEncoding(bool CFI) const {
|
||||||
|
@ -155,8 +155,8 @@ public:
|
|||||||
const MCSection *getTLSExtraDataSection() const {
|
const MCSection *getTLSExtraDataSection() const {
|
||||||
return TLSExtraDataSection;
|
return TLSExtraDataSection;
|
||||||
}
|
}
|
||||||
virtual const MCSection *getWin64EHFuncTableSection() const = 0;
|
virtual const MCSection *getWin64EHFuncTableSection(StringRef suffix)const=0;
|
||||||
virtual const MCSection *getWin64EHTableSection() const = 0;
|
virtual const MCSection *getWin64EHTableSection(StringRef suffix) const = 0;
|
||||||
|
|
||||||
/// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
|
/// shouldEmitUsedDirectiveFor - This hook allows targets to selectively
|
||||||
/// decide not to emit the UsedDirective for some symbols in llvm.used.
|
/// decide not to emit the UsedDirective for some symbols in llvm.used.
|
||||||
|
@ -977,8 +977,10 @@ void MCAsmStreamer::EmitWin64EHHandlerData() {
|
|||||||
// cause the section switch to be visible in the emitted assembly.
|
// cause the section switch to be visible in the emitted assembly.
|
||||||
// We only do this so the section switch that terminates the handler
|
// We only do this so the section switch that terminates the handler
|
||||||
// data block is visible.
|
// data block is visible.
|
||||||
|
MCWin64EHUnwindInfo *CurFrame = getCurrentW64UnwindInfo();
|
||||||
|
StringRef suffix=MCWin64EHUnwindEmitter::GetSectionSuffix(CurFrame->Function);
|
||||||
const MCSection *xdataSect =
|
const MCSection *xdataSect =
|
||||||
getContext().getTargetAsmInfo().getWin64EHTableSection();
|
getContext().getTargetAsmInfo().getWin64EHTableSection(suffix);
|
||||||
if (xdataSect)
|
if (xdataSect)
|
||||||
SwitchSectionNoChange(xdataSect);
|
SwitchSectionNoChange(xdataSect);
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
#include "llvm/MC/MCWin64EH.h"
|
#include "llvm/MC/MCWin64EH.h"
|
||||||
#include "llvm/MC/MCStreamer.h"
|
#include "llvm/MC/MCStreamer.h"
|
||||||
#include "llvm/MC/MCContext.h"
|
#include "llvm/MC/MCContext.h"
|
||||||
|
#include "llvm/MC/MCSymbol.h"
|
||||||
|
#include "llvm/MC/MCSectionCOFF.h"
|
||||||
#include "llvm/MC/MCExpr.h"
|
#include "llvm/MC/MCExpr.h"
|
||||||
#include "llvm/Target/TargetAsmInfo.h"
|
#include "llvm/Target/TargetAsmInfo.h"
|
||||||
|
|
||||||
@ -199,13 +201,33 @@ static void EmitUnwindInfo(MCStreamer &streamer, MCWin64EHUnwindInfo *info) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StringRef MCWin64EHUnwindEmitter::GetSectionSuffix(const MCSymbol *func) {
|
||||||
|
if (!func || !func->isInSection()) return "";
|
||||||
|
const MCSection *section = &func->getSection();
|
||||||
|
const MCSectionCOFF *COFFSection;
|
||||||
|
if ((COFFSection = dyn_cast<MCSectionCOFF>(section))) {
|
||||||
|
StringRef name = COFFSection->getSectionName();
|
||||||
|
size_t dollar = name.find('$');
|
||||||
|
size_t dot = name.find('.', 1);
|
||||||
|
if (dollar == StringRef::npos && dot == StringRef::npos)
|
||||||
|
return "";
|
||||||
|
if (dot == StringRef::npos)
|
||||||
|
return name.substr(dollar);
|
||||||
|
if (dollar == StringRef::npos || dot < dollar)
|
||||||
|
return name.substr(dot);
|
||||||
|
return name.substr(dollar);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
void MCWin64EHUnwindEmitter::EmitUnwindInfo(MCStreamer &streamer,
|
void MCWin64EHUnwindEmitter::EmitUnwindInfo(MCStreamer &streamer,
|
||||||
MCWin64EHUnwindInfo *info) {
|
MCWin64EHUnwindInfo *info) {
|
||||||
// Switch sections (the static function above is meant to be called from
|
// Switch sections (the static function above is meant to be called from
|
||||||
// here and from Emit().
|
// here and from Emit().
|
||||||
MCContext &context = streamer.getContext();
|
MCContext &context = streamer.getContext();
|
||||||
const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
|
const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
|
||||||
const MCSection *xdataSect = asmInfo.getWin64EHTableSection();
|
const MCSection *xdataSect =
|
||||||
|
asmInfo.getWin64EHTableSection(GetSectionSuffix(info->Function));
|
||||||
streamer.SwitchSection(xdataSect);
|
streamer.SwitchSection(xdataSect);
|
||||||
|
|
||||||
llvm::EmitUnwindInfo(streamer, info);
|
llvm::EmitUnwindInfo(streamer, info);
|
||||||
@ -215,15 +237,21 @@ void MCWin64EHUnwindEmitter::Emit(MCStreamer &streamer) {
|
|||||||
MCContext &context = streamer.getContext();
|
MCContext &context = streamer.getContext();
|
||||||
// Emit the unwind info structs first.
|
// Emit the unwind info structs first.
|
||||||
const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
|
const TargetAsmInfo &asmInfo = context.getTargetAsmInfo();
|
||||||
const MCSection *xdataSect = asmInfo.getWin64EHTableSection();
|
for (unsigned i = 0; i < streamer.getNumW64UnwindInfos(); ++i) {
|
||||||
streamer.SwitchSection(xdataSect);
|
MCWin64EHUnwindInfo &info = streamer.getW64UnwindInfo(i);
|
||||||
for (unsigned i = 0; i < streamer.getNumW64UnwindInfos(); ++i)
|
const MCSection *xdataSect =
|
||||||
llvm::EmitUnwindInfo(streamer, &streamer.getW64UnwindInfo(i));
|
asmInfo.getWin64EHTableSection(GetSectionSuffix(info.Function));
|
||||||
|
streamer.SwitchSection(xdataSect);
|
||||||
|
llvm::EmitUnwindInfo(streamer, &info);
|
||||||
|
}
|
||||||
// Now emit RUNTIME_FUNCTION entries.
|
// Now emit RUNTIME_FUNCTION entries.
|
||||||
const MCSection *pdataSect = asmInfo.getWin64EHFuncTableSection();
|
for (unsigned i = 0; i < streamer.getNumW64UnwindInfos(); ++i) {
|
||||||
streamer.SwitchSection(pdataSect);
|
MCWin64EHUnwindInfo &info = streamer.getW64UnwindInfo(i);
|
||||||
for (unsigned i = 0; i < streamer.getNumW64UnwindInfos(); ++i)
|
const MCSection *pdataSect =
|
||||||
EmitRuntimeFunction(streamer, &streamer.getW64UnwindInfo(i));
|
asmInfo.getWin64EHFuncTableSection(GetSectionSuffix(info.Function));
|
||||||
|
streamer.SwitchSection(pdataSect);
|
||||||
|
EmitRuntimeFunction(streamer, &info);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // End of namespace llvm
|
} // End of namespace llvm
|
||||||
|
Reference in New Issue
Block a user