We normally want to ignore SHT_NOBITS sections when computing offsets. The sh_offset of section itself seems to be irrelevant and
- If the section is in the middle of a PT_LOAD, it will make no difference on the computed offset of the followup section.
- If it is in the end of a PT_LOAD, we want to avoid its alignment changing the offset of the followup sections.
The issue is if it is at the start of the PT_LOAD. In that case we do have to align it so that the following sections have congruent address and offset module the page size. We were not handling this case.
This should fix freebsd kernel link.