This patch replaces flush with a last ditch attempt at synchronizing the section list with the linker script "AST".
The synchronization in a bit of a hack and should in time be avoided by creating the AST earlier so that modifications can be made directly to it instead of modifying the section list and synchronizing it back.
This is the main step for fixing https://bugs.llvm.org/show_bug.cgi?id=32816. With this in place I think the only missing thing would be to have processCommands assign section indexes as dummy offsets so that the sort in OutputSection::finalize works.
With this LinkerScript::assignAddresses becomes much simpler, which should help with the thunk work.
This needs a comment.