Skip to content

Commit

Permalink
ABI fixes for 9.3.1 from scox@usms.org.
Browse files Browse the repository at this point in the history
  • Loading branch information
wrwilliams authored and cuviper committed Mar 14, 2017
1 parent ba05f95 commit 3739826
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 65 deletions.
9 changes: 7 additions & 2 deletions common/h/dyntypes.h
Expand Up @@ -124,8 +124,13 @@

namespace Dyninst
{
typedef uintptr_t Address;
typedef uintptr_t Offset;
#if defined(_WIN64)
typedef uintptr_t Address;
typedef uintptr_t Offset;
#else
typedef unsigned long Address;
typedef unsigned long Offset;
#endif

#if defined(_MSC_VER)
typedef int PID;
Expand Down
2 changes: 1 addition & 1 deletion common/src/Types.h
Expand Up @@ -170,7 +170,7 @@ using namespace Dyninst;
static const Address ADDR_NULL = (Address)(0);
#else
#define ADDR_NULL (0)
typedef uintptr_t Address;
typedef unsigned long Address;
#endif
/* Note the inherent assumption that the size of a "long" integer matches
that of an address (void*) on every supported Paradyn/Dyninst system!
Expand Down
2 changes: 1 addition & 1 deletion dyninstAPI/h/BPatch_instruction.h
Expand Up @@ -69,7 +69,7 @@ class BPATCH_DLL_EXPORT BPatch_instruction {
public:

BPatch_instruction(internal_instruction *insn,
uintptr_t _addr);
Dyninst::Address _addr);
virtual ~BPatch_instruction();

void getInstruction(const unsigned char *&_buffer, unsigned char &_length);
Expand Down
12 changes: 6 additions & 6 deletions dyninstAPI/h/BPatch_memoryAccess_NP.h
Expand Up @@ -121,27 +121,27 @@ class BPATCH_DLL_EXPORT BPatch_memoryAccess : public BPatch_instruction
static BPatch_memoryAccess* init_tables();

// initializes only the first access; #bytes is a constant
BPatch_memoryAccess(internal_instruction *, uintptr_t _addr,
BPatch_memoryAccess(internal_instruction *, Dyninst::Address _addr,
bool _isLoad, bool _isStore, unsigned int _bytes,
long _imm, int _ra, int _rb, unsigned int _scale = 0,
int _cond = -1, bool _nt = false);

// initializes only the first access; #bytes is an expression w/scale
BPatch_memoryAccess(internal_instruction *insn, uintptr_t _addr,
BPatch_memoryAccess(internal_instruction *insn, Dyninst::Address _addr,
bool _isinternal_Load, bool _isStore,
long _imm_s, int _ra_s, int _rb_s, unsigned int _scale_s,
long _imm_c, int _ra_c, int _rb_c, unsigned int _scale_c,
int _cond, bool _nt, int _preFcn = -1);

// initializes only the first access; #bytes is an expression
BPatch_memoryAccess(internal_instruction *insn, uintptr_t _addr,
BPatch_memoryAccess(internal_instruction *insn, Dyninst::Address _addr,
bool _isLoad, bool _isStore, bool _isPrefetch,
long _imm_s, int _ra_s, int _rb_s,
long _imm_c, int _ra_c, int _rb_c,
unsigned short _preFcn);

// initializes only the first access; #bytes is an expression & not a prefetch
BPatch_memoryAccess(internal_instruction *insn, uintptr_t _addr,
BPatch_memoryAccess(internal_instruction *insn, Dyninst::Address _addr,
bool _isLoad, bool _isStore, long _imm_s, int _ra_s, int _rb_s,
long _imm_c, int _ra_c, int _rb_c);

Expand All @@ -156,14 +156,14 @@ class BPATCH_DLL_EXPORT BPatch_memoryAccess : public BPatch_instruction
int _cond, bool _nt);

// initializes both accesses; #bytes is a constant
BPatch_memoryAccess(internal_instruction *insn, uintptr_t _addr,
BPatch_memoryAccess(internal_instruction *insn, Dyninst::Address _addr,
bool _isLoad, bool _isStore, unsigned int _bytes,
long _imm, int _ra, int _rb, unsigned int _scale,
bool _isLoad2, bool _isStore2, unsigned int _bytes2,
long _imm2, int _ra2, int _rb2, unsigned int _scale2);

// initializes both accesses; #bytes is an expression & not a prefetch
BPatch_memoryAccess(internal_instruction *insn, uintptr_t _addr, bool _isLoad, bool _isStore,
BPatch_memoryAccess(internal_instruction *insn, Dyninst::Address _addr, bool _isLoad, bool _isStore,
long _imm_s, int _ra_s, int _rb_s, unsigned int _scale_s,
long _imm_c, int _ra_c, int _rb_c, unsigned int _scale_c,
bool _isLoad2, bool _isStore2, long _imm2_s, int _ra2_s,
Expand Down
2 changes: 1 addition & 1 deletion dyninstAPI/src/BPatch_memoryAccess.C
Expand Up @@ -33,10 +33,10 @@
#include <stdlib.h>
#include <string.h>

#include "../../common/src/Types.h"
#include "BPatch_memoryAccess_NP.h"
#include "BPatch_Vector.h"
#include "BPatch_point.h"
#include "../../common/src/Types.h"

BPatch_addrSpec_NP::BPatch_addrSpec_NP(long _imm, int _ra, int _rb, int _scale) :
imm(_imm),
Expand Down
104 changes: 50 additions & 54 deletions dyninstAPI/src/Relocation/Transformers/Movement-analysis.C
Expand Up @@ -125,18 +125,6 @@ bool PCSensitiveTransformer::process(RelocBlock *reloc, RelocGraph *g) {
continue;
}

AssignList sensitiveAssignments;
// This function also returns the sensitive assignments
if (!isPCSensitive(insn,
addr,
func,
block,
sensitiveAssignments)) {
//cerr << "Instruction " << insn->format() << " not PC sensitive, skipping" << endl;
continue;
}

Sens_++;

// sensitivity_cerr << "Instruction is sensitive @ " << hex << addr << dec << endl;

Expand All @@ -146,71 +134,79 @@ bool PCSensitiveTransformer::process(RelocBlock *reloc, RelocGraph *g) {
bool approx = false;
Absloc dest;

AssignList sensitiveAssignments;
if (insnIsThunkCall(insn, addr, dest)) {
relocation_cerr << "\tThunk @ " << hex << addr << dec << endl;
handleThunkCall(reloc, g, iter, dest);
intSens_++;
extSens_++;
thunk_++;
continue;
}

if (exceptionSensitive(addr+insn->size(), block)) {
} else if (exceptionSensitive(addr+insn->size(), block)) {
extSens = true;
sensitivity_cerr << "\tException sensitive @ " << hex << addr << dec << endl;
}

if (!queryCache(block, addr, intSens, extSens)) {
for (AssignList::iterator a_iter = sensitiveAssignments.begin();
a_iter != sensitiveAssignments.end(); ++a_iter) {

//cerr << "Forward slice from " << (*a_iter)->format() << hex << " @ " << addr << " (parse of " << (*a_iter)->addr() << dec << ") in func " << block->func()->prettyName() << endl;

Graph::Ptr slice = forwardSlice(*a_iter,
block->llb(),
func->ifunc());

if (!slice) {
// Safe assumption, as always
// sensitivity_cerr << "\t slice failed!" << endl;
approx = true;
}
else {
if (slice->size() > 10) {
// HACK around a problem with slice sizes
approx = true;
}
else if (!determineSensitivity(slice, intSens, extSens)) {
// Analysis failed for some reason... go conservative
// cerr << "\t Warning: sensitivity analysis failed!" << endl;
// This function also returns the sensitive assignments
else if (isPCSensitive(insn,
addr,
func,
block,
sensitiveAssignments)) {
Sens_++;

if (!queryCache(block, addr, intSens, extSens)) {
for (AssignList::iterator a_iter = sensitiveAssignments.begin();
a_iter != sensitiveAssignments.end(); ++a_iter) {

//cerr << "Forward slice from " << (*a_iter)->format() << hex << " @ " << addr << " (parse of " << (*a_iter)->addr() << dec << ") in func " << block->func()->prettyName() << endl;

Graph::Ptr slice = forwardSlice(*a_iter,
block->llb(),
func->ifunc());

if (!slice) {
// Safe assumption, as always
// sensitivity_cerr << "\t slice failed!" << endl;
approx = true;
}
else {
//sensitivity_cerr << "\t sens analysis returned " << (intSens ? "intSens" : "") << " / "
if (slice->size() > 10) {
// HACK around a problem with slice sizes
approx = true;
}
else if (!determineSensitivity(slice, intSens, extSens)) {
// Analysis failed for some reason... go conservative
// cerr << "\t Warning: sensitivity analysis failed!" << endl;
approx = true;
}
else {
//sensitivity_cerr << "\t sens analysis returned " << (intSens ? "intSens" : "") << " / "
//<< (extSens ? "extSens" : "") << endl;
}
}
}

if (approx || (intSens && extSens)) {
break;
if (approx || (intSens && extSens)) {
break;
}
}
}
}

if (approx && !adhoc_required) {
overApprox_++;
intSens = true;
extSens = true;
} else {
if (extSens) {
extSens_++;
}
if (intSens) {
intSens_++;
if (approx && !adhoc_required) {
overApprox_++;
intSens = true;
extSens = true;
} else {
if (extSens) {
extSens_++;
}
if (intSens) {
intSens_++;
}
}
}



if (extSens) {
sensitivity_cerr << "\tExtSens @ " << std::hex << addr << std::dec << endl;

Expand Down

0 comments on commit 3739826

Please sign in to comment.