mirror of
https://github.com/ipxe/ipxe
synced 2025-12-19 02:50:25 +03:00
[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.
This commit is contained in:
@@ -192,10 +192,12 @@ sub unpack_init {
|
|||||||
my $instr = shift;
|
my $instr = shift;
|
||||||
|
|
||||||
# Accept both short and near jumps
|
# Accept both short and near jumps
|
||||||
( my $jump, my $offset ) = unpack ( "CS", $instr );
|
my $jump = unpack ( "C", $instr );
|
||||||
if ( $jump == JMP_SHORT ) {
|
if ( $jump == JMP_SHORT ) {
|
||||||
|
my $offset = unpack ( "xC", $instr );
|
||||||
return ( $offset + 5 );
|
return ( $offset + 5 );
|
||||||
} elsif ( $jump == JMP_NEAR ) {
|
} elsif ( $jump == JMP_NEAR ) {
|
||||||
|
my $offset = unpack ( "xS", $instr );
|
||||||
return ( $offset + 6 );
|
return ( $offset + 6 );
|
||||||
} elsif ( $jump == 0 ) {
|
} elsif ( $jump == 0 ) {
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user