From bd5189a96d88a27f8c7da29491876ec3790af138 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 27 Aug 2008 20:36:30 +0100 Subject: [PATCH] [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. --- src/util/Option/ROM.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/util/Option/ROM.pm b/src/util/Option/ROM.pm index 7a1bb883..a86d3262 100644 --- a/src/util/Option/ROM.pm +++ b/src/util/Option/ROM.pm @@ -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;