The GDT base and ljmp offset both need relocating to absolute values.
Instead of building LZ with these values containing 0, and dynamically
calculating base + offset, build LZ with with data already relative to
lz_start. This allows the data to be relocated simply by adding the LZ base.
Introduce lz_offset(), to generate data relative to lz_start, and use it for
the GDT base and ljmp offset fields. Adjust the relocation logic to match,
which is simplified to two add instructions.
In addition, simplify some related code. sl_header can reuse lz_offset()
directly. Using lea and indirecting resulting answer isn't necessary; load
the GDT using a base-relative reference directly. Finally, avoid opencoding
the ljmpl instruction.
The GDT base and ljmp offset both need relocating to absolute values.
Instead of building LZ with these values containing 0, and dynamically calculating base + offset, build LZ with with data already relative to lz_start. This allows the data to be relocated simply by adding the LZ base.
Introduce lz_offset(), to generate data relative to lz_start, and use it for the GDT base and ljmp offset fields. Adjust the relocation logic to match, which is simplified to two add instructions.
In addition, simplify some related code. sl_header can reuse lz_offset() directly. Using lea and indirecting resulting answer isn't necessary; load the GDT using a base-relative reference directly. Finally, avoid opencoding the ljmpl instruction.
Signed-off-by: Andrew Cooper andrew.cooper3@citrix.com