Linkers (ld.bfd/gold/lld) place the section header table at the very
end. The section header table is optional in executable/shared objects,
so this allows tools to strip it. In addition, if we add or remove a
section, the size of the section header table will change. Placing the
section header table in the end keeps section offsets unchanged.
yaml2obj currently places the section header table immediately after the
program header. Follow what linkers do to make offset updating easier.
Seems you can just call initELFHeader later instead?
I think placing it right before OS.write((const char *)&Header, sizeof(Header)); in ELFState<ELFT>::writeELF should work.
It needs rewriting the assignment:
to something like
but seems there are no more problems?