I suggest to get rid of LinkerScript::adjustSectionsBeforeSorting() method.
It is used to force output sections that does not have any input sections
to be live when they have data bytes commands or assignments inside.
Probably there is no reason to delay that and do separatelly, I believe it
is simpler to set this flag when we do linker script commands proccessing,
as at that place we already know everything we need to do that.
I don't like to do more things in a single for-loop. Previously, this loop was just three lines. Now it does more things. It is hard to understand now. Please try to split it into smaller pieces.