Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[util] Fix interpretation of short jumps in Option::ROM
Option::ROM was assuming that ROM images using a short jump
instruction for the init entry point would have a zero byte at offset
5; this is not necessarily true.
  • Loading branch information
Michael Brown committed Aug 27, 2008
1 parent d5732b0 commit bd5189a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/util/Option/ROM.pm
Expand Up @@ -192,10 +192,12 @@ sub unpack_init {
my $instr = shift;

# Accept both short and near jumps
( my $jump, my $offset ) = unpack ( "CS", $instr );
my $jump = unpack ( "C", $instr );
if ( $jump == JMP_SHORT ) {
my $offset = unpack ( "xC", $instr );
return ( $offset + 5 );
} elsif ( $jump == JMP_NEAR ) {
my $offset = unpack ( "xS", $instr );
return ( $offset + 6 );
} elsif ( $jump == 0 ) {
return 0;
Expand Down

0 comments on commit bd5189a

Please sign in to comment.