Selaa lähdekoodia

[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 16 vuotta sitten
vanhempi
commit
bd5189a96d
1 muutettua tiedostoa jossa 3 lisäystä ja 1 poistoa
  1. 3
    1
      src/util/Option/ROM.pm

+ 3
- 1
src/util/Option/ROM.pm Näytä tiedosto

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

Loading…
Peruuta
Tallenna