The --section-start <name>=<address> needs to be translated into equivalent linker script commands. There are a couple of problems with the existing implementation:
- The --section-start with the lowest address is assumed to be at the start of the map. This assumption is incorrect, we have to iterate through the SectionStartMap to find the lowest address.
- The addresses in --section-start were being over-aligned when the sections were marked as PageAlign. This is inconsistent with the use of SectionStartMap in fixHeaders(), and can cause problems when the PageAlign causes an "unable to move location counter backward" error when the --section-start section with PageAlign is aligned to an address higher than the next --section-start without PageAlign. The ld.bfd and ld.gold seem to be more consistent with this interpretation but this is not a well specified area.
This change fixes the problems above and also corrects a typo in which fabricateDefaultCommands() is called with the wrong parameter, it should be called with AllocateHeader not Config->MaxPageSize.
The problems were found while investigating dmikulin's comments in D31888 , however I don't think that these changes are directly related.