本文整理汇总了C#中ILCompiler.DependencyAnalysis.ObjectDataBuilder.EmitReloc方法的典型用法代码示例。如果您正苦于以下问题:C# ObjectDataBuilder.EmitReloc方法的具体用法?C# ObjectDataBuilder.EmitReloc怎么用?C# ObjectDataBuilder.EmitReloc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ILCompiler.DependencyAnalysis.ObjectDataBuilder
的用法示例。
在下文中一共展示了ObjectDataBuilder.EmitReloc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EncodeEHInfo
private ObjectNode.ObjectData EncodeEHInfo()
{
var builder = new ObjectDataBuilder();
builder.Alignment = 1;
// TODO: Filter out duplicate clauses
builder.EmitCompressedUInt((uint)_ehClauses.Length);
for (int i = 0; i < _ehClauses.Length; i++)
{
var clause = _ehClauses[i];
RhEHClauseKind clauseKind;
if (((clause.Flags & CORINFO_EH_CLAUSE_FLAGS.CORINFO_EH_CLAUSE_FAULT) != 0) ||
((clause.Flags & CORINFO_EH_CLAUSE_FLAGS.CORINFO_EH_CLAUSE_FINALLY) != 0))
{
clauseKind = RhEHClauseKind.RH_EH_CLAUSE_FAULT;
}
else
if ((clause.Flags & CORINFO_EH_CLAUSE_FLAGS.CORINFO_EH_CLAUSE_FILTER) != 0)
{
clauseKind = RhEHClauseKind.RH_EH_CLAUSE_FILTER;
}
else
{
clauseKind = RhEHClauseKind.RH_EH_CLAUSE_TYPED;
}
builder.EmitCompressedUInt((uint)clause.TryOffset);
// clause.TryLength returned by the JIT is actually end offset...
// https://github.com/dotnet/coreclr/issues/3585
int tryLength = (int)clause.TryLength - (int)clause.TryOffset;
builder.EmitCompressedUInt((uint)((tryLength << 2) | (int)clauseKind));
switch (clauseKind)
{
case RhEHClauseKind.RH_EH_CLAUSE_TYPED:
{
builder.EmitCompressedUInt(clause.HandlerOffset);
var methodIL = (MethodIL)HandleToObject((IntPtr)_methodScope);
var type = (TypeDesc)methodIL.GetObject((int)clause.ClassTokenOrOffset);
var typeSymbol = _compilation.NodeFactory.NecessaryTypeSymbol(type);
RelocType rel = (_compilation.NodeFactory.Target.IsWindows) ?
RelocType.IMAGE_REL_BASED_ABSOLUTE :
RelocType.IMAGE_REL_BASED_REL32;
builder.EmitReloc(typeSymbol, rel);
}
break;
case RhEHClauseKind.RH_EH_CLAUSE_FAULT:
builder.EmitCompressedUInt(clause.HandlerOffset);
break;
case RhEHClauseKind.RH_EH_CLAUSE_FILTER:
builder.EmitCompressedUInt(clause.HandlerOffset);
builder.EmitCompressedUInt(clause.ClassTokenOrOffset);
break;
}
}
return builder.ToObjectData();
}