mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-01-09 14:08:03 -05:00
Merge remote-tracking branch 'origin/GP-6237_CrossbuildUniqueFix' into
patch (Closes #8784)
This commit is contained in:
@@ -4,9 +4,9 @@
|
|||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@@ -316,7 +316,7 @@ void SleighBuilder::buildEmpty(Constructor *ct,int4 secnum)
|
|||||||
void SleighBuilder::setUniqueOffset(const Address &addr)
|
void SleighBuilder::setUniqueOffset(const Address &addr)
|
||||||
|
|
||||||
{
|
{
|
||||||
uniqueoffset = (addr.getOffset() & uniquemask)<<4;
|
uniqueoffset = (addr.getOffset() & uniquemask)<<8;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Constructor
|
/// \brief Constructor
|
||||||
@@ -337,7 +337,7 @@ SleighBuilder::SleighBuilder(ParserWalker *w,DisassemblyCache *dcache,PcodeCache
|
|||||||
const_space = cspc;
|
const_space = cspc;
|
||||||
uniq_space = uspc;
|
uniq_space = uspc;
|
||||||
uniquemask = umask;
|
uniquemask = umask;
|
||||||
uniqueoffset = (walker->getAddr().getOffset() & uniquemask)<<4;
|
uniqueoffset = (walker->getAddr().getOffset() & uniquemask)<<8;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SleighBuilder::appendBuild(OpTpl *bld,int4 secnum)
|
void SleighBuilder::appendBuild(OpTpl *bld,int4 secnum)
|
||||||
|
|||||||
@@ -3548,73 +3548,77 @@ bool SleighCompile::forceExportSize(ConstructTpl *ct)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief If the given Varnode is in the \e unique space, shift its offset up by \b sa bits
|
/// \brief Insert a region of zero bits into an address offset
|
||||||
|
///
|
||||||
|
/// \param addr is the address offset
|
||||||
|
/// \return the modified offset
|
||||||
|
uintb SleighCompile::insertCrossBuildRegion(uintb addr)
|
||||||
|
|
||||||
|
{
|
||||||
|
uintb upperbits = (addr >> UNIQUE_CROSSBUILD_POSITION) << (UNIQUE_CROSSBUILD_POSITION + UNIQUE_CROSSBUILD_NUMBITS);
|
||||||
|
uintb lowerbits = (addr << (8*sizeof(uintb) - UNIQUE_CROSSBUILD_POSITION)) >> (8*sizeof(uintb) - UNIQUE_CROSSBUILD_POSITION);
|
||||||
|
return upperbits | lowerbits;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// \brief If the given Varnode is in the \e unique space, insert a region of zero bits
|
||||||
///
|
///
|
||||||
/// \param vn is the given Varnode
|
/// \param vn is the given Varnode
|
||||||
/// \param sa is the number of bits to shift by
|
void SleighCompile::shiftUniqueVn(VarnodeTpl *vn)
|
||||||
void SleighCompile::shiftUniqueVn(VarnodeTpl *vn,int4 sa)
|
|
||||||
|
|
||||||
{
|
{
|
||||||
if (vn->getSpace().isUniqueSpace() && (vn->getOffset().getType() == ConstTpl::real)) {
|
if (vn->getSpace().isUniqueSpace() && (vn->getOffset().getType() == ConstTpl::real)) {
|
||||||
uintb val = vn->getOffset().getReal();
|
uintb val = insertCrossBuildRegion(vn->getOffset().getReal());
|
||||||
val <<= sa;
|
|
||||||
vn->setOffset(val);
|
vn->setOffset(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Shift the offset up by \b sa bits for any Varnode used by the given op in the \e unique space
|
/// \brief Insert a region of zero bits for any Varnode used by the given op in the \e unique space
|
||||||
///
|
///
|
||||||
/// \param op is the given op
|
/// \param op is the given op
|
||||||
/// \param sa is the number of bits to shift by
|
void SleighCompile::shiftUniqueOp(OpTpl *op)
|
||||||
void SleighCompile::shiftUniqueOp(OpTpl *op,int4 sa)
|
|
||||||
|
|
||||||
{
|
{
|
||||||
VarnodeTpl *outvn = op->getOut();
|
VarnodeTpl *outvn = op->getOut();
|
||||||
if (outvn != (VarnodeTpl *)0)
|
if (outvn != (VarnodeTpl *)0)
|
||||||
shiftUniqueVn(outvn,sa);
|
shiftUniqueVn(outvn);
|
||||||
for(int4 i=0;i<op->numInput();++i)
|
for(int4 i=0;i<op->numInput();++i)
|
||||||
shiftUniqueVn(op->getIn(i),sa);
|
shiftUniqueVn(op->getIn(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Shift the offset up for both \e dynamic or \e static Varnode aspects in the \e unique space
|
/// \brief Insert a region of zero bits for both \e dynamic or \e static Varnode aspects in the \e unique space
|
||||||
///
|
///
|
||||||
/// \param hand is a handle template whose aspects should be modified
|
/// \param hand is a handle template whose aspects should be modified
|
||||||
/// \param sa is the number of bits to shift by
|
void SleighCompile::shiftUniqueHandle(HandleTpl *hand)
|
||||||
void SleighCompile::shiftUniqueHandle(HandleTpl *hand,int4 sa)
|
|
||||||
|
|
||||||
{
|
{
|
||||||
if (hand->getSpace().isUniqueSpace() && (hand->getPtrSpace().getType() == ConstTpl::real)
|
if (hand->getSpace().isUniqueSpace() && (hand->getPtrSpace().getType() == ConstTpl::real)
|
||||||
&& (hand->getPtrOffset().getType() == ConstTpl::real)) {
|
&& (hand->getPtrOffset().getType() == ConstTpl::real)) {
|
||||||
uintb val = hand->getPtrOffset().getReal();
|
uintb val = insertCrossBuildRegion(hand->getPtrOffset().getReal());
|
||||||
val <<= sa;
|
|
||||||
hand->setPtrOffset(val);
|
hand->setPtrOffset(val);
|
||||||
}
|
}
|
||||||
else if (hand->getPtrSpace().isUniqueSpace() && (hand->getPtrOffset().getType() == ConstTpl::real)) {
|
else if (hand->getPtrSpace().isUniqueSpace() && (hand->getPtrOffset().getType() == ConstTpl::real)) {
|
||||||
uintb val = hand->getPtrOffset().getReal();
|
uintb val = insertCrossBuildRegion(hand->getPtrOffset().getReal());
|
||||||
val <<= sa;
|
|
||||||
hand->setPtrOffset(val);
|
hand->setPtrOffset(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hand->getTempSpace().isUniqueSpace() && (hand->getTempOffset().getType() == ConstTpl::real)) {
|
if (hand->getTempSpace().isUniqueSpace() && (hand->getTempOffset().getType() == ConstTpl::real)) {
|
||||||
uintb val = hand->getTempOffset().getReal();
|
uintb val = insertCrossBuildRegion(hand->getTempOffset().getReal());
|
||||||
val <<= sa;
|
|
||||||
hand->setTempOffset(val);
|
hand->setTempOffset(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// \brief Shift the offset up for any Varnode in the \e unique space for all p-code in the given section
|
/// \brief Insert a region of zero bits for any Varnode in the \e unique space for all p-code in the given section
|
||||||
///
|
///
|
||||||
/// \param tpl is the given p-code section
|
/// \param tpl is the given p-code section
|
||||||
/// \param sa is the number of bits to shift by
|
void SleighCompile::shiftUniqueConstruct(ConstructTpl *tpl)
|
||||||
void SleighCompile::shiftUniqueConstruct(ConstructTpl *tpl,int4 sa)
|
|
||||||
|
|
||||||
{
|
{
|
||||||
HandleTpl *result = tpl->getResult();
|
HandleTpl *result = tpl->getResult();
|
||||||
if (result != (HandleTpl *)0)
|
if (result != (HandleTpl *)0)
|
||||||
shiftUniqueHandle(result,sa);
|
shiftUniqueHandle(result);
|
||||||
const vector<OpTpl *> &vec( tpl->getOpvec() );
|
const vector<OpTpl *> &vec( tpl->getOpvec() );
|
||||||
for(int4 i=0;i<vec.size();++i)
|
for(int4 i=0;i<vec.size();++i)
|
||||||
shiftUniqueOp(vec[i],sa);
|
shiftUniqueOp(vec[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// With \b crossbuilds, temporaries may need to survive across instructions in a packet, so here we
|
/// With \b crossbuilds, temporaries may need to survive across instructions in a packet, so here we
|
||||||
@@ -3626,7 +3630,6 @@ void SleighCompile::checkUniqueAllocation(void)
|
|||||||
if (unique_allocatemask == 0) return; // We don't have any crossbuild directives
|
if (unique_allocatemask == 0) return; // We don't have any crossbuild directives
|
||||||
|
|
||||||
unique_allocatemask = 0xff; // Provide 8 bits of free space
|
unique_allocatemask = 0xff; // Provide 8 bits of free space
|
||||||
int4 sa = 8;
|
|
||||||
int4 secsize = sections.size(); // This is the upper bound for section numbers
|
int4 secsize = sections.size(); // This is the upper bound for section numbers
|
||||||
SubtableSymbol *sym = root; // Start with the instruction table
|
SubtableSymbol *sym = root; // Start with the instruction table
|
||||||
int4 i = -1;
|
int4 i = -1;
|
||||||
@@ -3636,11 +3639,11 @@ void SleighCompile::checkUniqueAllocation(void)
|
|||||||
Constructor *ct = sym->getConstructor(j);
|
Constructor *ct = sym->getConstructor(j);
|
||||||
ConstructTpl *tpl = ct->getTempl();
|
ConstructTpl *tpl = ct->getTempl();
|
||||||
if (tpl != (ConstructTpl *)0)
|
if (tpl != (ConstructTpl *)0)
|
||||||
shiftUniqueConstruct(tpl,sa);
|
shiftUniqueConstruct(tpl);
|
||||||
for(int4 k=0;k<secsize;++k) {
|
for(int4 k=0;k<secsize;++k) {
|
||||||
ConstructTpl *namedtpl = ct->getNamedTempl(k);
|
ConstructTpl *namedtpl = ct->getNamedTempl(k);
|
||||||
if (namedtpl != (ConstructTpl *)0)
|
if (namedtpl != (ConstructTpl *)0)
|
||||||
shiftUniqueConstruct(namedtpl,sa);
|
shiftUniqueConstruct(namedtpl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i+=1;
|
i+=1;
|
||||||
@@ -3648,7 +3651,8 @@ void SleighCompile::checkUniqueAllocation(void)
|
|||||||
sym = tables[i];
|
sym = tables[i];
|
||||||
}
|
}
|
||||||
uint4 ubase = getUniqueBase(); // We have to adjust the unique base
|
uint4 ubase = getUniqueBase(); // We have to adjust the unique base
|
||||||
ubase <<= sa;
|
ubase += 1 << UNIQUE_CROSSBUILD_POSITION;
|
||||||
|
ubase <<= UNIQUE_CROSSBUILD_NUMBITS;
|
||||||
setUniqueBase(ubase);
|
setUniqueBase(ubase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -301,6 +301,8 @@ public:
|
|||||||
/// various set*() methods prior to calling run_compilation.
|
/// various set*() methods prior to calling run_compilation.
|
||||||
class SleighCompile : public SleighBase {
|
class SleighCompile : public SleighBase {
|
||||||
friend class SleighPcode;
|
friend class SleighPcode;
|
||||||
|
static const int4 UNIQUE_CROSSBUILD_POSITION = 8;
|
||||||
|
static const int4 UNIQUE_CROSSBUILD_NUMBITS = 8;
|
||||||
public:
|
public:
|
||||||
SleighPcode pcode; ///< The p-code parsing (sub)engine
|
SleighPcode pcode; ///< The p-code parsing (sub)engine
|
||||||
private:
|
private:
|
||||||
@@ -351,10 +353,11 @@ private:
|
|||||||
bool finalizeSections(Constructor *big,SectionVector *vec); ///< Do final checks, expansions, and linking for p-code sections
|
bool finalizeSections(Constructor *big,SectionVector *vec); ///< Do final checks, expansions, and linking for p-code sections
|
||||||
static VarnodeTpl *findSize(const ConstTpl &offset,const ConstructTpl *ct);
|
static VarnodeTpl *findSize(const ConstTpl &offset,const ConstructTpl *ct);
|
||||||
static bool forceExportSize(ConstructTpl *ct);
|
static bool forceExportSize(ConstructTpl *ct);
|
||||||
static void shiftUniqueVn(VarnodeTpl *vn,int4 sa);
|
static uintb insertCrossBuildRegion(uintb addr);
|
||||||
static void shiftUniqueOp(OpTpl *op,int4 sa);
|
static void shiftUniqueVn(VarnodeTpl *vn);
|
||||||
static void shiftUniqueHandle(HandleTpl *hand,int4 sa);
|
static void shiftUniqueOp(OpTpl *op);
|
||||||
static void shiftUniqueConstruct(ConstructTpl *tpl,int4 sa);
|
static void shiftUniqueHandle(HandleTpl *hand);
|
||||||
|
static void shiftUniqueConstruct(ConstructTpl *tpl);
|
||||||
static string formatStatusMessage(const Location* loc, const string &msg);
|
static string formatStatusMessage(const Location* loc, const string &msg);
|
||||||
void checkUniqueAllocation(void); ///< Modify temporary Varnode offsets to support \b crossbuilds
|
void checkUniqueAllocation(void); ///< Modify temporary Varnode offsets to support \b crossbuilds
|
||||||
void process(void); ///< Do all post processing on the parsed data structures
|
void process(void); ///< Do all post processing on the parsed data structures
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@@ -88,7 +88,7 @@ public abstract class PcodeEmit {
|
|||||||
addressFactory = language.getAddressFactory();
|
addressFactory = language.getAddressFactory();
|
||||||
uniq_space = addressFactory.getUniqueSpace();
|
uniq_space = addressFactory.getUniqueSpace();
|
||||||
uniquemask = language.getUniqueAllocationMask();
|
uniquemask = language.getUniqueAllocationMask();
|
||||||
uniqueoffset = (startAddress.getOffset() & uniquemask) << 4;
|
uniqueoffset = (startAddress.getOffset() & uniquemask) << 8;
|
||||||
}
|
}
|
||||||
else { // This can happen for CallFixup snippets, but these don't need their temporary vars patched up
|
else { // This can happen for CallFixup snippets, but these don't need their temporary vars patched up
|
||||||
language = null;
|
language = null;
|
||||||
@@ -120,7 +120,7 @@ public abstract class PcodeEmit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setUniqueOffset(Address addr) {
|
private void setUniqueOffset(Address addr) {
|
||||||
uniqueoffset = (addr.getOffset() & uniquemask) << 4;
|
uniqueoffset = (addr.getOffset() & uniquemask) << 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Address getStartAddress() {
|
public Address getStartAddress() {
|
||||||
@@ -504,7 +504,7 @@ public abstract class PcodeEmit {
|
|||||||
VarnodeData[] dyncache = null;
|
VarnodeData[] dyncache = null;
|
||||||
VarnodeTpl vn, outvn;
|
VarnodeTpl vn, outvn;
|
||||||
int isize = opt.getInput().length;
|
int isize = opt.getInput().length;
|
||||||
|
|
||||||
if (isize > incache.length) {
|
if (isize > incache.length) {
|
||||||
incache = new VarnodeData[isize];
|
incache = new VarnodeData[isize];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,9 @@
|
|||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
* You may obtain a copy of the License at
|
* You may obtain a copy of the License at
|
||||||
*
|
*
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
*
|
*
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
@@ -53,6 +53,9 @@ public class SleighCompile extends SleighBase {
|
|||||||
|
|
||||||
static boolean yydebug = false;
|
static boolean yydebug = false;
|
||||||
|
|
||||||
|
private static int UNIQUE_CROSSBUILD_POSITION = 8; // Starting bit with a unique address for crossbuild collision region
|
||||||
|
private static int UNIQUE_CROSSBUILD_NUMBITS = 8; // Number of bits within a unique address for crossbuild collision region
|
||||||
|
|
||||||
private static boolean isLocationIsh(Object o) {
|
private static boolean isLocationIsh(Object o) {
|
||||||
if (o instanceof Location) {
|
if (o instanceof Location) {
|
||||||
return true;
|
return true;
|
||||||
@@ -1589,64 +1592,74 @@ public class SleighCompile extends SleighBase {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void shiftUniqueVn(VarnodeTpl vn, int sa) {
|
/**
|
||||||
entry("shiftUniqueVn", vn, sa);
|
* Insert a region of zero bits into an address offset
|
||||||
|
* @param addr is the address offset
|
||||||
|
* @return the modified offset
|
||||||
|
*/
|
||||||
|
private static long insertCrossBuildRegion(long addr) {
|
||||||
|
long upperbits = (addr >> UNIQUE_CROSSBUILD_POSITION) << (UNIQUE_CROSSBUILD_POSITION +
|
||||||
|
UNIQUE_CROSSBUILD_NUMBITS);
|
||||||
|
long lowerbits =
|
||||||
|
(addr << (64 - UNIQUE_CROSSBUILD_POSITION)) >>> (64 - UNIQUE_CROSSBUILD_POSITION);
|
||||||
|
return upperbits | lowerbits;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void shiftUniqueVn(VarnodeTpl vn) {
|
||||||
|
entry("shiftUniqueVn", vn);
|
||||||
// If the varnode is in the unique space, shift its offset up by -sa- bits
|
// If the varnode is in the unique space, shift its offset up by -sa- bits
|
||||||
if (vn.getSpace().isUniqueSpace() &&
|
if (vn.getSpace().isUniqueSpace() &&
|
||||||
(vn.getOffset().getType() == ConstTpl.const_type.real)) {
|
(vn.getOffset().getType() == ConstTpl.const_type.real)) {
|
||||||
long val = vn.getOffset().getReal();
|
long val = insertCrossBuildRegion(vn.getOffset().getReal());
|
||||||
val <<= sa;
|
|
||||||
vn.setOffset(val);
|
vn.setOffset(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void shiftUniqueOp(OpTpl op, int sa) {
|
private static void shiftUniqueOp(OpTpl op) {
|
||||||
entry("shiftUniqueOp", op, sa);
|
entry("shiftUniqueOp", op);
|
||||||
// Shift the offset up by -sa- bits for any varnode used by this -op- in the unique space
|
// Shift the offset up by -sa- bits for any varnode used by this -op- in the unique space
|
||||||
VarnodeTpl outvn = op.getOut();
|
VarnodeTpl outvn = op.getOut();
|
||||||
if (outvn != null) {
|
if (outvn != null) {
|
||||||
shiftUniqueVn(outvn, sa);
|
shiftUniqueVn(outvn);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < op.numInput(); ++i) {
|
for (int i = 0; i < op.numInput(); ++i) {
|
||||||
shiftUniqueVn(op.getIn(i), sa);
|
shiftUniqueVn(op.getIn(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void shiftUniqueHandle(HandleTpl hand, int sa) {
|
private static void shiftUniqueHandle(HandleTpl hand) {
|
||||||
entry("shiftUniqueHandle", hand, sa);
|
entry("shiftUniqueHandle", hand);
|
||||||
// Shift the offset up by -sa- bits, for either the dynamic or static varnode aspects that are in the unique space
|
// Shift the offset up by -sa- bits, for either the dynamic or static varnode aspects that are in the unique space
|
||||||
if (hand.getSpace().isUniqueSpace() &&
|
if (hand.getSpace().isUniqueSpace() &&
|
||||||
(hand.getPtrSpace().getType() == ConstTpl.const_type.real) &&
|
(hand.getPtrSpace().getType() == ConstTpl.const_type.real) &&
|
||||||
(hand.getPtrOffset().getType() == ConstTpl.const_type.real)) {
|
(hand.getPtrOffset().getType() == ConstTpl.const_type.real)) {
|
||||||
long val = hand.getPtrOffset().getReal();
|
long val = insertCrossBuildRegion(hand.getPtrOffset().getReal());
|
||||||
val <<= sa;
|
|
||||||
hand.setPtrOffset(val);
|
hand.setPtrOffset(val);
|
||||||
}
|
}
|
||||||
else if (hand.getPtrSpace().isUniqueSpace() &&
|
else if (hand.getPtrSpace().isUniqueSpace() &&
|
||||||
(hand.getPtrOffset().getType() == ConstTpl.const_type.real)) {
|
(hand.getPtrOffset().getType() == ConstTpl.const_type.real)) {
|
||||||
long val = hand.getPtrOffset().getReal();
|
long val = insertCrossBuildRegion(hand.getPtrOffset().getReal());
|
||||||
val <<= sa;
|
|
||||||
hand.setPtrOffset(val);
|
hand.setPtrOffset(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hand.getTempSpace().isUniqueSpace() &&
|
if (hand.getTempSpace().isUniqueSpace() &&
|
||||||
(hand.getTempOffset().getType() == ConstTpl.const_type.real)) {
|
(hand.getTempOffset().getType() == ConstTpl.const_type.real)) {
|
||||||
long val = hand.getTempOffset().getReal();
|
long val = insertCrossBuildRegion(hand.getTempOffset().getReal());
|
||||||
val <<= sa;
|
|
||||||
hand.setTempOffset(val);
|
hand.setTempOffset(val);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void shiftUniqueConstruct(ConstructTpl tpl, int sa) {
|
private static void shiftUniqueConstruct(ConstructTpl tpl) {
|
||||||
entry("shiftUniqueConstruct", tpl, sa);
|
entry("shiftUniqueConstruct", tpl);
|
||||||
// Shift the offset up by -sa- bits, for any varnode in the unique space associated with this template
|
// Shift the offset up by -sa- bits, for any varnode in the unique space associated with this template
|
||||||
HandleTpl result = tpl.getResult();
|
HandleTpl result = tpl.getResult();
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
shiftUniqueHandle(result, sa);
|
shiftUniqueHandle(result);
|
||||||
}
|
}
|
||||||
VectorSTL<OpTpl> vec = tpl.getOpvec();
|
VectorSTL<OpTpl> vec = tpl.getOpvec();
|
||||||
for (int i = 0; i < vec.size(); ++i) {
|
for (int i = 0; i < vec.size(); ++i) {
|
||||||
shiftUniqueOp(vec.get(i), sa);
|
shiftUniqueOp(vec.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1659,7 +1672,6 @@ public class SleighCompile extends SleighBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unique_allocatemask = 0xff; // Provide 8 bits of free space
|
unique_allocatemask = 0xff; // Provide 8 bits of free space
|
||||||
int sa = 8;
|
|
||||||
int secsize = sections.size(); // This is the upper bound for section numbers
|
int secsize = sections.size(); // This is the upper bound for section numbers
|
||||||
SubtableSymbol sym = root; // Start with the instruction table
|
SubtableSymbol sym = root; // Start with the instruction table
|
||||||
int i = -1;
|
int i = -1;
|
||||||
@@ -1669,12 +1681,12 @@ public class SleighCompile extends SleighBase {
|
|||||||
Constructor ct = sym.getConstructor(j);
|
Constructor ct = sym.getConstructor(j);
|
||||||
ConstructTpl tpl = ct.getTempl();
|
ConstructTpl tpl = ct.getTempl();
|
||||||
if (tpl != null) {
|
if (tpl != null) {
|
||||||
shiftUniqueConstruct(tpl, sa);
|
shiftUniqueConstruct(tpl);
|
||||||
}
|
}
|
||||||
for (int k = 0; k < secsize; ++k) {
|
for (int k = 0; k < secsize; ++k) {
|
||||||
ConstructTpl namedtpl = ct.getNamedTempl(k);
|
ConstructTpl namedtpl = ct.getNamedTempl(k);
|
||||||
if (namedtpl != null) {
|
if (namedtpl != null) {
|
||||||
shiftUniqueConstruct(namedtpl, sa);
|
shiftUniqueConstruct(namedtpl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1685,7 +1697,8 @@ public class SleighCompile extends SleighBase {
|
|||||||
sym = tables.get(i);
|
sym = tables.get(i);
|
||||||
}
|
}
|
||||||
long ubase = getUniqueBase(); // We have to adjust the unique base
|
long ubase = getUniqueBase(); // We have to adjust the unique base
|
||||||
ubase <<= sa;
|
ubase += 1 << UNIQUE_CROSSBUILD_POSITION;
|
||||||
|
ubase <<= UNIQUE_CROSSBUILD_NUMBITS;
|
||||||
setUniqueBase(ubase);
|
setUniqueBase(ubase);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user