Skip to content

Commit c445f57

Browse files
committed
fix:
1 parent 1a5910e commit c445f57

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

lib/Core/Executor.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -817,11 +817,8 @@ ObjectPair Executor::addExternalObject(ExecutionState &state, const void *addr,
817817
auto mo = memory->allocateFixed(reinterpret_cast<std::uint64_t>(addr), size,
818818
nullptr, type);
819819
ObjectState *os = bindObjectInState(state, mo, type, false);
820-
ref<ConstantExpr> seg =
821-
Expr::createPointer(reinterpret_cast<std::uint64_t>(addr));
822820
for (unsigned i = 0; i < size; i++) {
823-
ref<Expr> byte = ConstantExpr::create(((uint8_t *)addr)[i], Expr::Int8);
824-
os->write(i, PointerExpr::create(seg, byte));
821+
os->write8(i, ((uint8_t *)addr)[i], reinterpret_cast<std::uint64_t>(addr));
825822
}
826823
if (isReadOnly)
827824
os->setReadOnly(true);
@@ -2039,12 +2036,10 @@ MemoryObject *Executor::serializeLandingpad(ExecutionState &state,
20392036
ObjectState *os =
20402037
bindObjectInState(state, mo, typeSystemManager->getUnknownType(), false);
20412038
for (unsigned i = 0; i < serialized.size(); i++) {
2042-
ref<ConstantExpr> sec = ConstantExpr::create(serialized[i], Expr::Int8);
20432039
if (pointerMask.at(i)) {
2044-
ref<ConstantExpr> seg = Expr::createPointer(pointerMask.at(i));
2045-
os->write(i, PointerExpr::create(seg, sec));
2040+
os->write8(i, serialized[i], pointerMask.at(i));
20462041
} else {
2047-
os->write(i, sec);
2042+
os->write8(i, serialized[i]);
20482043
}
20492044
}
20502045

lib/Core/Memory.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,11 @@ void ObjectState::write8(unsigned offset, uint8_t value) {
231231
ConstantExpr::create(0, Context::get().getPointerWidth()));
232232
}
233233

234+
void ObjectState::write8(unsigned offset, uint8_t value, uint64_t base) {
235+
valueOS.writeWidth(offset, value);
236+
baseOS.writeWidth(offset, base);
237+
}
238+
234239
void ObjectState::write8(unsigned offset, ref<Expr> value) {
235240
wasWritten = true;
236241
if (auto pointer = dyn_cast<PointerExpr>(value)) {

lib/Core/Memory.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,8 @@ class ObjectState {
448448
void write16(unsigned offset, uint16_t value);
449449
void write32(unsigned offset, uint32_t value);
450450
void write64(unsigned offset, uint64_t value);
451+
452+
void write8(unsigned offset, uint8_t value, uint64_t base);
451453
void print() const;
452454

453455
bool isAccessableFrom(KType *) const;

0 commit comments

Comments
 (0)