With the current code if the script has a PHDRS we always obey and try to allocate a header. This can cause Min - HeaderSize to underflow.
It looks like bfd actually prints an error for this case. With this patch we do the same.
Found while looking at pr36515
I think you can avoid introducing this flag and
just iterate over Script->PhdrsCommands to find
Cmd.HasPhdrs || Cmd.HasFilehdr instead ?