@@ -65,7 +65,6 @@ static unsigned long efi_pe_entry;
6565static unsigned long efi32_pe_entry ;
6666static unsigned long kernel_info ;
6767static unsigned long startup_64 ;
68- static unsigned long _ehead ;
6968static unsigned long _end ;
7069
7170/*----------------------------------------------------------------------*/
@@ -229,35 +228,22 @@ static void update_pecoff_setup_and_reloc(unsigned int size)
229228#endif
230229}
231230
232- static void update_pecoff_text (unsigned int text_start , unsigned int file_sz ,
233- unsigned int init_sz )
231+ static void update_pecoff_text (unsigned int text_start , unsigned int file_sz )
234232{
235233 unsigned int pe_header ;
236234 unsigned int text_sz = file_sz - text_start ;
237- unsigned int bss_sz = init_sz - file_sz ;
235+ unsigned int bss_sz = _end - text_sz ;
238236
239237 pe_header = get_unaligned_le32 (& buf [0x3c ]);
240238
241- /*
242- * The PE/COFF loader may load the image at an address which is
243- * misaligned with respect to the kernel_alignment field in the setup
244- * header.
245- *
246- * In order to avoid relocating the kernel to correct the misalignment,
247- * add slack to allow the buffer to be aligned within the declared size
248- * of the image.
249- */
250- bss_sz += CONFIG_PHYSICAL_ALIGN ;
251- init_sz += CONFIG_PHYSICAL_ALIGN ;
252-
253239 /*
254240 * Size of code: Subtract the size of the first sector (512 bytes)
255241 * which includes the header.
256242 */
257243 put_unaligned_le32 (file_sz - 512 + bss_sz , & buf [pe_header + 0x1c ]);
258244
259245 /* Size of image */
260- put_unaligned_le32 (init_sz , & buf [pe_header + 0x50 ]);
246+ put_unaligned_le32 (file_sz + bss_sz , & buf [pe_header + 0x50 ]);
261247
262248 /*
263249 * Address of entry point for PE/COFF executable
@@ -308,8 +294,7 @@ static void efi_stub_entry_update(void)
308294
309295static inline void update_pecoff_setup_and_reloc (unsigned int size ) {}
310296static inline void update_pecoff_text (unsigned int text_start ,
311- unsigned int file_sz ,
312- unsigned int init_sz ) {}
297+ unsigned int file_sz ) {}
313298static inline void efi_stub_defaults (void ) {}
314299static inline void efi_stub_entry_update (void ) {}
315300
@@ -360,7 +345,6 @@ static void parse_zoffset(char *fname)
360345 PARSE_ZOFS (p , efi32_pe_entry );
361346 PARSE_ZOFS (p , kernel_info );
362347 PARSE_ZOFS (p , startup_64 );
363- PARSE_ZOFS (p , _ehead );
364348 PARSE_ZOFS (p , _end );
365349
366350 p = strchr (p , '\n' );
@@ -371,7 +355,7 @@ static void parse_zoffset(char *fname)
371355
372356int main (int argc , char * * argv )
373357{
374- unsigned int i , sz , setup_sectors , init_sz ;
358+ unsigned int i , sz , setup_sectors ;
375359 int c ;
376360 u32 sys_size ;
377361 struct stat sb ;
@@ -442,31 +426,9 @@ int main(int argc, char ** argv)
442426 buf [0x1f1 ] = setup_sectors - 1 ;
443427 put_unaligned_le32 (sys_size , & buf [0x1f4 ]);
444428
445- init_sz = get_unaligned_le32 (& buf [0x260 ]);
446- #ifdef CONFIG_EFI_STUB
447- /*
448- * The decompression buffer will start at ImageBase. When relocating
449- * the compressed kernel to its end, we must ensure that the head
450- * section does not get overwritten. The head section occupies
451- * [i, i + _ehead), and the destination is [init_sz - _end, init_sz).
452- *
453- * At present these should never overlap, because 'i' is at most 32k
454- * because of SETUP_SECT_MAX, '_ehead' is less than 1k, and the
455- * calculation of INIT_SIZE in boot/header.S ensures that
456- * 'init_sz - _end' is at least 64k.
457- *
458- * For future-proofing, increase init_sz if necessary.
459- */
460-
461- if (init_sz - _end < i + _ehead ) {
462- init_sz = (i + _ehead + _end + 4095 ) & ~4095 ;
463- put_unaligned_le32 (init_sz , & buf [0x260 ]);
464- }
465- #endif
466- update_pecoff_text (setup_sectors * 512 , i + (sys_size * 16 ), init_sz );
429+ update_pecoff_text (setup_sectors * 512 , i + (sys_size * 16 ));
467430
468431 efi_stub_entry_update ();
469-
470432 /* Update kernel_info offset. */
471433 put_unaligned_le32 (kernel_info , & buf [0x268 ]);
472434
0 commit comments