Adapted from an example in PR35478. If in the future we are going to ignore zero sized sections we need to account for linker scripts with location counter expressions or data creating functions such as BYTE. These linker script commands may be evaluated late on so testing early for OutputSection size will miss them.
This should only be committed once the revert of r318924 has been done (D40710).