This is an alternative implementation of -n and -N to D61201 as this was suggested as a review comment. Instead of skipping page alignment when -n (--nmagic) and -N (--omagic) are used but leaving the values of the Config->MaxPageSize and Target->PageSize unchanged, we instead:
- Use Config->CommonPageSize to store the appropriate Target->PageSize value
- When -n or -N is used we set the Config->MaxPageSize and Config->PageSize to 1 so all page-alignment does nothing.
- We still have to account for -n and -N meaning -Bstatic.
- We still have to not allocate headers unless explicitly stated in the linker script.
As we now have a modifiable Config->CommonPageSize it becomes trivial to support the -zcommon-page-size command line option so I've done that and added a test case for it. This could be split into a different patch if it makes sense. I've also added a test to show the effect of increasing -zcommon-page-size. Other test cases have been taken from D61201
This approach has the advantage that none of the page alignment statements have to be changed, and any future ones we add won't need guarding. It has the disadvantage that the CONSTANT(MAXPAGESIZE) and CONSTANT(COMMONPAGESIZE) linker script commands will be affected when -n or -N is used. There is at least one linkerscript in Tianocore edk2 that (ab)uses -n -z common-page-size=0x20 to use CONSTANT(COMMONPAGESIZE) as if it were a preprocessor macro set with -D in the compiler. The usual approach to this is to pre-process the linkerscript.