Unfortunately, compiling the DEBUG shell using the small code model is not sufficient in all cases to get a successful build when the toolchain defaults to the tiny code model. The reason is that not only the Shell binary itself should be built using the small code model, all Shell component libraries that are linked into the Shell binary via NULL library class resolution should use the small code model as well.
So override the code model and function alignment for DEBUG builds of UEFI_APPLICATION modules when using GCC 4.9 (which is the only toolchain that uses the tiny model). This should affect all Shell component libraries in addition to the Shell core binary. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <[email protected]> --- ArmVirtPkg/ArmVirt.dsc.inc | 21 ++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc index 49e4264ee8a4..fbd710cb870d 100644 --- a/ArmVirtPkg/ArmVirt.dsc.inc +++ b/ArmVirtPkg/ArmVirt.dsc.inc @@ -406,3 +406,24 @@ [Components.common] gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|8000 } + +[BuildOptions.AARCH64.EDKII.UEFI_APPLICATION] + # + # The bulk of the Shell functionality is implemented by UEFI_APPLICATION + # libraries that are linked into the Shell binary via NULL library class + # resolution. Since the Shell built in DEBUG mode exceeds the 1 MB range of + # the AARCH64 tiny code model which we use by default on GCC 4.9 and later, + # the .text and .data sections of the remaining base libraries (which are + # built using the tiny code model regardless of the model we use for + # UEFI_APPLICATION modules) should be kept as close together as possible. + # + # By reverting to 8 byte function alignment for UEFI_APPLICATION modules + # (which is usually the default, but will be lowered to 4 if we are using the + # tiny code model) and letting the linker sort its input by alignment, we can + # force all UEFI_APPLICATION small code model .text input sections to appear + # first in the binary. The remaining base libraries will end up in close + # proximity of each other at the end of the image, preventing out of range + # problems when relocating their tiny model (+/- 1 MB) symbol references. + # + DEBUG_GCC49_*_CC_FLAGS = -mcmodel=small -falign-functions=8 + DEBUG_GCC49_*_DLINK_FLAGS = -z common-page-size=0x1000 -- 2.5.0 _______________________________________________ edk2-devel mailing list [email protected] https://lists.01.org/mailman/listinfo/edk2-devel

