本文整理汇总了C++中Section::getVMA方法的典型用法代码示例。如果您正苦于以下问题:C++ Section::getVMA方法的具体用法?C++ Section::getVMA怎么用?C++ Section::getVMA使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Section
的用法示例。
在下文中一共展示了Section::getVMA方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
static void
MapPrescanBytes(const Section& sect, const BinSection& bsd, int* bytes)
{
while (!bsd.length.isOkSize(*bytes * 8, 0, 0))
*bytes *= 2;
while (!sect.getLMA().isOkSize(*bytes * 8, 0, 0))
*bytes *= 2;
while (!sect.getVMA().isOkSize(*bytes * 8, 0, 0))
*bytes *= 2;
}
示例2: if
void
CoffSymbol::Write(Bytes& bytes,
const Symbol& sym,
DiagnosticsEngine& diags,
StringTable& strtab) const
{
int vis = sym.getVisibility();
IntNum value = 0;
unsigned int scnum = 0xfffe; // -2 = debugging symbol
unsigned long scnlen = 0; // for sect auxent
unsigned long nreloc = 0; // for sect auxent
// Look at symrec for value/scnum/etc.
Location loc;
if (sym.getLabel(&loc))
{
Section* sect = 0;
if (loc.bc)
sect = loc.bc->getContainer()->getSection();
// it's a label: get value and offset.
// If there is not a section, leave as debugging symbol.
if (sect)
{
CoffSection* coffsect = sect->getAssocData<CoffSection>();
assert(coffsect != 0);
scnum = coffsect->m_scnum;
scnlen = coffsect->m_size;
nreloc = sect->getRelocs().size();
value = sect->getVMA();
if (loc.bc)
value += loc.getOffset();
}
}
else if (const Expr* equ_expr_c = sym.getEqu())
{
Expr equ_expr = *equ_expr_c;
if (!ExpandEqu(equ_expr))
{
diags.Report(sym.getDefSource(), diag::err_equ_circular_reference);
return;
}
SimplifyCalcDist(equ_expr, diags);
// trivial case: simple integer
if (equ_expr.isIntNum())
{
scnum = 0xffff; // -1 = absolute symbol
value = equ_expr.getIntNum();
}
else
{
// otherwise might contain relocatable value (e.g. symbol alias)
std::auto_ptr<Expr> equ_expr_p(new Expr);
equ_expr_p->swap(equ_expr);
Value val(64, equ_expr_p);
val.setSource(sym.getDefSource());
if (!val.Finalize(diags, diag::err_equ_too_complex))
return;
if (val.isComplexRelative())
{
diags.Report(sym.getDefSource(), diag::err_equ_too_complex);
return;
}
// set section appropriately based on if value is relative
if (val.isRelative())
{
SymbolRef rel = val.getRelative();
Location loc;
if (!rel->getLabel(&loc) || !loc.bc)
{
// Referencing an undefined label?
// GNU as silently allows this... but doesn't gen the symbol?
// We make it an error instead.
diags.Report(sym.getDefSource(), diag::err_equ_too_complex);
return;
}
Section* sect = loc.bc->getContainer()->getSection();
CoffSection* coffsect = sect->getAssocData<CoffSection>();
assert(coffsect != 0);
scnum = coffsect->m_scnum;
value = sect->getVMA() + loc.getOffset();
}
else
{
scnum = 0xffff; // -1 = absolute symbol
value = 0;
}
// add in any remaining absolute portion
if (Expr* abs = val.getAbs())
{
SimplifyCalcDist(*abs, diags);
if (abs->isIntNum())
value += abs->getIntNum();
else
diags.Report(sym.getDefSource(), diag::err_equ_not_integer);
//.........这里部分代码省略.........
示例3: assert
void
XdfObject::DirSection(DirectiveInfo& info, Diagnostic& diags)
{
assert(info.isObject(m_object));
NameValues& nvs = info.getNameValues();
NameValue& sectname_nv = nvs.front();
if (!sectname_nv.isString())
{
diags.Report(sectname_nv.getValueRange().getBegin(),
diag::err_value_string_or_id);
return;
}
llvm::StringRef sectname = sectname_nv.getString();
Section* sect = m_object.FindSection(sectname);
bool first = true;
if (sect)
first = sect->isDefault();
else
sect = AppendSection(sectname, info.getSource(), diags);
XdfSection* xsect = sect->getAssocData<XdfSection>();
assert(xsect != 0);
m_object.setCurSection(sect);
sect->setDefault(false);
if (xsect->bits != 0)
m_object.getArch()->setVar("mode_bits", xsect->bits); // reapply
// No name/values, so nothing more to do
if (nvs.size() <= 1)
return;
// Ignore flags if we've seen this section before
if (!first)
{
diags.Report(info.getSource(), diag::warn_section_redef_flags);
return;
}
// Parse section flags
IntNum align;
bool has_align = false;
unsigned long bss = sect->isBSS();
unsigned long code = sect->isCode();
IntNum vma = sect->getVMA();
IntNum lma = sect->getLMA();
unsigned long flat = xsect->flat;
DirHelpers helpers;
helpers.Add("use16", false,
TR1::bind(&DirResetFlag, _1, _2, &xsect->bits, 16));
helpers.Add("use32", false,
TR1::bind(&DirResetFlag, _1, _2, &xsect->bits, 32));
helpers.Add("use64", false,
TR1::bind(&DirResetFlag, _1, _2, &xsect->bits, 64));
helpers.Add("bss", false, TR1::bind(&DirSetFlag, _1, _2, &bss, 1));
helpers.Add("nobss", false, TR1::bind(&DirClearFlag, _1, _2, &bss, 1));
helpers.Add("code", false, TR1::bind(&DirSetFlag, _1, _2, &code, 1));
helpers.Add("data", false, TR1::bind(&DirClearFlag, _1, _2, &code, 1));
helpers.Add("flat", false, TR1::bind(&DirSetFlag, _1, _2, &flat, 1));
helpers.Add("noflat", false, TR1::bind(&DirClearFlag, _1, _2, &flat, 1));
helpers.Add("absolute", true,
TR1::bind(&DirIntNum, _1, _2, &m_object, &lma,
&xsect->has_addr));
helpers.Add("virtual", true,
TR1::bind(&DirIntNum, _1, _2, &m_object, &vma,
&xsect->has_vaddr));
helpers.Add("align", true,
TR1::bind(&DirIntNumPower2, _1, _2, &m_object, &align,
&has_align));
helpers(++nvs.begin(), nvs.end(), info.getSource(), diags,
DirNameValueWarn);
if (has_align)
{
unsigned long aligni = align.getUInt();
// Check to see if alignment is supported size
// FIXME: Use actual value source location
if (aligni > 4096)
{
diags.Report(info.getSource(),
diags.getCustomDiagID(Diagnostic::Error,
"XDF does not support alignments > 4096"));
}
sect->setAlign(aligni);
}
sect->setBSS(bss);
sect->setCode(code);
sect->setVMA(vma);
sect->setLMA(lma);
xsect->flat = flat;
if (xsect->bits != 0)
//.........这里部分代码省略.........