Current implementation handles empty section only in case it contains symbols. Unfortunately it's not the only case when empty section should be kept. Consider the following example:
SECTIONS { .eh_frame_hdr : { *(.eh_frame_hdr) } __eh_frame_hdr_start = ADDR(.eh_frame_hdr); }
This script cannot be processed by lld in case there is no .eh_frame_hdr section in the target image.
The proposed implementation doesn't have side effects (no extended PT_LOADs and no empty sections in the target image) and doesn't look more complex than the existing one
Don't you have to adjust the value?