Commit e520e5da authored by yangguo's avatar yangguo Committed by Commit bot

[snapshot] do not embed string addresses in code.

Doing so in a -pie build would make the snapshot non-deterministic.

R=bmeurer@chromium.org
BUG=v8:5233

Review-Url: https://codereview.chromium.org/2178093003
Cr-Commit-Position: refs/heads/master@{#38042}
parent a5fae103
......@@ -2164,7 +2164,11 @@ void Assembler::stop(const char* msg, Condition cond, int32_t code) {
} else {
svc(kStopCode + kMaxStopCode, cond);
}
emit(reinterpret_cast<Instr>(msg));
// Do not embed the message string address! We used to do this, but that
// made snapshots created from position-independent executable builds
// non-deterministic.
// TODO(yangguo): remove this field entirely.
nop();
}
#else // def __arm__
if (cond != al) {
......
......@@ -1364,16 +1364,10 @@ int Decoder::DecodeType7(Instruction* instr) {
if (instr->Bit(24) == 1) {
if (instr->SvcValue() >= kStopCode) {
Format(instr, "stop'cond 'svc");
// Also print the stop message. Its address is encoded
// in the following 4 bytes.
out_buffer_pos_ += SNPrintF(out_buffer_ + out_buffer_pos_,
"\n %p %08x stop message: %s",
reinterpret_cast<void*>(instr
+ Instruction::kInstrSize),
*reinterpret_cast<uint32_t*>(instr
+ Instruction::kInstrSize),
*reinterpret_cast<char**>(instr
+ Instruction::kInstrSize));
out_buffer_pos_ += SNPrintF(
out_buffer_ + out_buffer_pos_, "\n %p %08x",
reinterpret_cast<void*>(instr + Instruction::kInstrSize),
*reinterpret_cast<uint32_t*>(instr + Instruction::kInstrSize));
// We have decoded 2 * Instruction::kInstrSize bytes.
return 2 * Instruction::kInstrSize;
} else {
......
......@@ -115,18 +115,11 @@ static void InitializeCoverage() {
void ArmDebugger::Stop(Instruction* instr) {
// Get the stop code.
uint32_t code = instr->SvcValue() & kStopCodeMask;
// Retrieve the encoded address, which comes just after this stop.
char* msg = *reinterpret_cast<char**>(sim_->get_pc()
+ Instruction::kInstrSize);
// Update this stop description.
if (sim_->isWatchedStop(code) && !sim_->watched_stops_[code].desc) {
sim_->watched_stops_[code].desc = msg;
}
// Print the stop message and code if it is not the default code.
if (code != kMaxStopCode) {
PrintF("Simulator hit stop %u: %s\n", code, msg);
PrintF("Simulator hit stop %u\n", code);
} else {
PrintF("Simulator hit %s\n", msg);
PrintF("Simulator hit\n");
}
sim_->set_pc(sim_->get_pc() + 2 * Instruction::kInstrSize);
Debug();
......
......@@ -1974,7 +1974,11 @@ void Assembler::stop(const char* msg, uint32_t code) {
// The Simulator will handle the stop instruction and get the message address.
// On MIPS stop() is just a special kind of break_().
break_(code, true);
emit(reinterpret_cast<Instr>(msg));
// Do not embed the message string address! We used to do this, but that
// made snapshots created from position-independent executable builds
// non-deterministic.
// TODO(yangguo): remove this field entirely.
nop();
#endif
}
......
......@@ -138,14 +138,7 @@ static void InitializeCoverage() {}
void MipsDebugger::Stop(Instruction* instr) {
// Get the stop code.
uint32_t code = instr->Bits(25, 6);
// Retrieve the encoded address, which comes just after this stop.
char* msg = *reinterpret_cast<char**>(sim_->get_pc() +
Instruction::kInstrSize);
// Update this stop description.
if (!sim_->watched_stops_[code].desc) {
sim_->watched_stops_[code].desc = msg;
}
PrintF("Simulator hit %s (%u)\n", msg, code);
PrintF("Simulator hit (%u)\n", code);
sim_->set_pc(sim_->get_pc() + 2 * Instruction::kInstrSize);
Debug();
}
......
......@@ -2225,7 +2225,11 @@ void Assembler::stop(const char* msg, uint32_t code) {
// The Simulator will handle the stop instruction and get the message address.
// On MIPS stop() is just a special kind of break_().
break_(code, true);
emit(reinterpret_cast<uint64_t>(msg));
// Do not embed the message string address! We used to do this, but that
// made snapshots created from position-independent executable builds
// non-deterministic.
// TODO(yangguo): remove this field entirely.
nop();
#endif
}
......
......@@ -803,13 +803,11 @@ int Decoder::DecodeBreakInstr(Instruction* instr) {
// This is stop(msg).
Format(instr, "break, code: 'code");
out_buffer_pos_ += SNPrintF(
out_buffer_ + out_buffer_pos_,
"\n%p %08" PRIx64 " stop msg: %s",
out_buffer_ + out_buffer_pos_, "\n%p %08" PRIx64,
static_cast<void*>(
reinterpret_cast<int32_t*>(instr + Instruction::kInstrSize)),
reinterpret_cast<uint64_t>(
*reinterpret_cast<char**>(instr + Instruction::kInstrSize)),
*reinterpret_cast<char**>(instr + Instruction::kInstrSize));
*reinterpret_cast<char**>(instr + Instruction::kInstrSize)));
// Size 3: the break_ instr, plus embedded 64-bit char pointer.
return 3 * Instruction::kInstrSize;
} else {
......
......@@ -152,14 +152,7 @@ static void InitializeCoverage() {}
void MipsDebugger::Stop(Instruction* instr) {
// Get the stop code.
uint32_t code = instr->Bits(25, 6);
// Retrieve the encoded address, which comes just after this stop.
char* msg = *reinterpret_cast<char**>(sim_->get_pc() +
Instruction::kInstrSize);
// Update this stop description.
if (!sim_->watched_stops_[code].desc) {
sim_->watched_stops_[code].desc = msg;
}
PrintF("Simulator hit %s (%u)\n", msg, code);
PrintF("Simulator hit (%u)\n", code);
// TODO(yuyin): 2 -> 3?
sim_->set_pc(sim_->get_pc() + 3 * Instruction::kInstrSize);
Debug();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment