mirror of
https://github.com/ipxe/ipxe
synced 2025-12-11 14:03:29 +03:00
[zbin] Change fixup semantics to support ROMs over 128k uncompressed
The option ROM header contains a one-byte field indicating the number of 512-byte sectors in the ROM image. Currently it is linked to contain the number of uncompressed sectors, with an instruction to the compressor to correct it. This causes link failure when the uncompressed size of the ROM image is over 128k. Fix by replacing the SUBx compressor fixup with an ADDx fixup that adds the total compressed output length, scaled as requested, to an addend stored in the field where the final length value will be placed. This is similar to the behavior of ELF relocations, and ensures that an overflow error will not be generated unless the compressed size is still too large for the field. This also allows us to do away with the _filesz_pgh and _filesz_sect calculations exported by the linker script. Output tested bitwise identical to the old SUBx mechanism on hd, dsk, lkrn, and rom prefixes, on both 32-bit and 64-bit processors. Modified-by: Michael Brown <mcb30@etherboot.org> Signed-off-by: Michael Brown <mcb30@etherboot.org>
This commit is contained in:
committed by
Michael Brown
parent
487347a0cd
commit
d5d68b2e31
@@ -146,9 +146,9 @@ got_sectors:
|
||||
/* Jump to loaded copy */
|
||||
ljmp $SYSSEG, $start_runtime
|
||||
|
||||
endseg: .word SYSSEG + _filesz_pgh
|
||||
endseg: .word SYSSEG
|
||||
.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
|
||||
.ascii "SUBW"
|
||||
.ascii "ADDW"
|
||||
.long endseg
|
||||
.long 16
|
||||
.long 0
|
||||
|
||||
@@ -65,10 +65,10 @@ max_sector:
|
||||
max_head:
|
||||
.byte 0
|
||||
load_length:
|
||||
.long _filesz_sect
|
||||
.long 0
|
||||
|
||||
.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
|
||||
.ascii "SUBL"
|
||||
.ascii "ADDL"
|
||||
.long load_length
|
||||
.long 512
|
||||
.long 0
|
||||
|
||||
@@ -94,10 +94,10 @@ setup_sects:
|
||||
root_flags:
|
||||
.word 0
|
||||
syssize:
|
||||
.long _filesz_pgh - PREFIXPGH
|
||||
.long -PREFIXPGH
|
||||
|
||||
.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
|
||||
.ascii "SUBL"
|
||||
.ascii "ADDL"
|
||||
.long syssize
|
||||
.long 16
|
||||
.long 0
|
||||
|
||||
@@ -30,16 +30,16 @@ segment_header:
|
||||
.byte 0
|
||||
.byte 0x04 /* Last segment */
|
||||
.long 0x00007e00
|
||||
imglen: .long _filesz - 512
|
||||
memlen: .long _filesz - 512
|
||||
imglen: .long -512
|
||||
memlen: .long -512
|
||||
.size segment_header, . - segment_header
|
||||
|
||||
.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
|
||||
.ascii "SUBL"
|
||||
.ascii "ADDL"
|
||||
.long imglen
|
||||
.long 1
|
||||
.long 0
|
||||
.ascii "SUBL"
|
||||
.ascii "ADDL"
|
||||
.long memlen
|
||||
.long 1
|
||||
.long 0
|
||||
|
||||
@@ -33,7 +33,7 @@ FILE_LICENCE ( GPL2_OR_LATER )
|
||||
.org 0x00
|
||||
romheader:
|
||||
.word 0xAA55 /* BIOS extension signature */
|
||||
romheader_size: .byte _filesz_sect /* Size in 512-byte blocks */
|
||||
romheader_size: .byte 0 /* Size in 512-byte blocks */
|
||||
jmp init /* Initialisation vector */
|
||||
checksum:
|
||||
.byte 0
|
||||
@@ -46,7 +46,7 @@ checksum:
|
||||
.size romheader, . - romheader
|
||||
|
||||
.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
|
||||
.ascii "SUBB"
|
||||
.ascii "ADDB"
|
||||
.long romheader_size
|
||||
.long 512
|
||||
.long 0
|
||||
@@ -61,23 +61,23 @@ pciheader:
|
||||
.byte 0x03 /* PCI data structure revision */
|
||||
.byte 0x02, 0x00, 0x00 /* Class code */
|
||||
pciheader_image_length:
|
||||
.word _filesz_sect /* Image length */
|
||||
.word 0 /* Image length */
|
||||
.word 0x0001 /* Revision level */
|
||||
.byte 0x00 /* Code type */
|
||||
.byte 0x80 /* Last image indicator */
|
||||
pciheader_runtime_length:
|
||||
.word _filesz_sect /* Maximum run-time image length */
|
||||
.word 0 /* Maximum run-time image length */
|
||||
.word 0x0000 /* Configuration utility code header */
|
||||
.word 0x0000 /* DMTF CLP entry point */
|
||||
.equ pciheader_len, . - pciheader
|
||||
.size pciheader, . - pciheader
|
||||
|
||||
.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
|
||||
.ascii "SUBW"
|
||||
.ascii "ADDW"
|
||||
.long pciheader_image_length
|
||||
.long 512
|
||||
.long 0
|
||||
.ascii "SUBW"
|
||||
.ascii "ADDW"
|
||||
.long pciheader_runtime_length
|
||||
.long 512
|
||||
.long 0
|
||||
|
||||
Reference in New Issue
Block a user