linker - Why EFI images require some extra padding before the PE/COFF header -


every efi image i've inspected has @ least 40h bytes of padding between ms-dos stub , pe signature unused in cases. it's filled zeros.

i'm writing linker , first plan have 0 padding in specified location seems uefi loader stopped responding after loading file. i've tried weird combinations merging dos header , pe header 1 location same problem occurred.

i tried entirely removing dos-stub , reason firmware still able recognize image too. usually, if image doesn't start mz signature, loader prints error messages , exits. i'm sure in case, it's parsing directly coff format because after writing invalid magic value optional header, loader recognizes , prints error message. problem still bugs out , prints nothing. hangs. parsing pe header normal. count on work on other machines?

i'm sure otherwise image working. if wasn't, when there padding, loader prints error message , exits instead of hanging. if image loaded , executed successfully, should print hello world message. happens when 10h padding present , began work perfectly. how accomplish such task? suggestions?


Comments