Przeglądaj źródła

[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 lat temu
rodzic
commit
bd5189a96d
1 zmienionych plików z 3 dodań i 1 usunięć
  1. 3
    1
      src/util/Option/ROM.pm

+ 3
- 1
src/util/Option/ROM.pm Wyświetl plik

@@ -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;

Ładowanie…
Anuluj
Zapisz