Commit 286f759e by Tom Tromey Committed by Tom Tromey

verify.cc (_Jv_BytecodeVerifier::branch_prepass): Set start_PC earlier, for error handling.

	* verify.cc (_Jv_BytecodeVerifier::branch_prepass): Set start_PC
	earlier, for error handling.
	(_Jv_BytecodeVerifier::note_branch_target): Fixed branch target
	check.

From-SVN: r47769
parent 8f25dc28
2001-12-07 Tom Tromey <tromey@redhat.com>
* verify.cc (_Jv_BytecodeVerifier::branch_prepass): Set start_PC
earlier, for error handling.
(_Jv_BytecodeVerifier::note_branch_target): Fixed branch target
check.
2001-12-06 Tom Tromey <tromey@redhat.com> 2001-12-06 Tom Tromey <tromey@redhat.com>
* verify.cc (_Jv_BytecodeVerifier::FLAG_JSR_TARGET): Removed. * verify.cc (_Jv_BytecodeVerifier::FLAG_JSR_TARGET): Removed.
......
...@@ -1254,8 +1254,11 @@ private: ...@@ -1254,8 +1254,11 @@ private:
void note_branch_target (int pc, bool is_jsr_target = false) void note_branch_target (int pc, bool is_jsr_target = false)
{ {
if (pc <= PC && ! (flags[pc] & FLAG_INSN_START)) // Don't check `pc <= PC', because we've advanced PC after
verify_fail ("branch not to instruction start"); // fetching the target and we haven't yet checked the next
// instruction.
if (pc < PC && ! (flags[pc] & FLAG_INSN_START))
verify_fail ("branch not to instruction start", start_PC);
flags[pc] |= FLAG_BRANCH_TARGET; flags[pc] |= FLAG_BRANCH_TARGET;
if (is_jsr_target) if (is_jsr_target)
{ {
...@@ -1395,6 +1398,9 @@ private: ...@@ -1395,6 +1398,9 @@ private:
PC = 0; PC = 0;
while (PC < current_method->code_length) while (PC < current_method->code_length)
{ {
// Set `start_PC' early so that error checking can have the
// correct value.
start_PC = PC;
flags[PC] |= FLAG_INSN_START; flags[PC] |= FLAG_INSN_START;
// If the previous instruction was a jsr, then the next // If the previous instruction was a jsr, then the next
...@@ -1404,7 +1410,6 @@ private: ...@@ -1404,7 +1410,6 @@ private:
note_branch_target (PC); note_branch_target (PC);
last_was_jsr = false; last_was_jsr = false;
start_PC = PC;
java_opcode opcode = (java_opcode) bytecode[PC++]; java_opcode opcode = (java_opcode) bytecode[PC++];
switch (opcode) switch (opcode)
{ {
......
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