Browse Source

[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.
tags/v0.9.4
Michael Brown 15 years ago
parent
commit
bd5189a96d
1 changed files with 3 additions and 1 deletions
  1. 3
    1
      src/util/Option/ROM.pm

+ 3
- 1
src/util/Option/ROM.pm View File

192
   my $instr = shift;
192
   my $instr = shift;
193
 
193
 
194
   # Accept both short and near jumps
194
   # Accept both short and near jumps
195
-  ( my $jump, my $offset ) = unpack ( "CS", $instr );
195
+  my $jump = unpack ( "C", $instr );
196
   if ( $jump == JMP_SHORT ) {
196
   if ( $jump == JMP_SHORT ) {
197
+    my $offset = unpack ( "xC", $instr );
197
     return ( $offset + 5 );
198
     return ( $offset + 5 );
198
   } elsif ( $jump == JMP_NEAR ) {
199
   } elsif ( $jump == JMP_NEAR ) {
200
+    my $offset = unpack ( "xS", $instr );
199
     return ( $offset + 6 );
201
     return ( $offset + 6 );
200
   } elsif ( $jump == 0 ) {
202
   } elsif ( $jump == 0 ) {
201
     return 0;
203
     return 0;

Loading…
Cancel
Save