On 27 December 2015 at 21:34, Ard Biesheuvel <[email protected]> wrote:
> On 27 December 2015 at 20:14, Leif Lindholm <[email protected]> wrote:
>> On Sun, Dec 27, 2015 at 08:02:34PM +0100, Ard Biesheuvel wrote:
>>> On 27 December 2015 at 18:58, Leif Lindholm <[email protected]> 
>>> wrote:
>>> > On Thu, Dec 24, 2015 at 02:03:16PM +0100, Ard Biesheuvel wrote:
>>> >> The tiny code model for AARCH64 is the most efficient model, since its
>>> >> symbol references are relative via a single 32-bit ADR instruction. This
>>> >> gives us a range of only +/- 1 MB, but this is sufficient for the vast
>>> >> majority of the modules that make up a typical EDK2 firmware. Since the
>>> >> reference is relative, it does not result in a fixup entry in the PE/COFF
>>> >> relocation table. Unlike the small code model, which uses ADRP 
>>> >> instructions,
>>> >> the tiny model does not impose section alignment requirements.
>>> >>
>>> >> However, in some cases, (e.g., the full Shell binary built in DEBUG mode)
>>> >> the resulting binary exceeds 1 MB, which may result in build errors if
>>> >> code at one end of the image references a symbol at the other end.
>>> >>
>>> >> Since the tiny and small code models can coexist in a single binary, we
>>> >> can work around this problem by making sure that tiny model .text and
>>> >> .data sections are emitted in close proximity to each other, by reducing
>>> >> the function alignment for tiny model code (which by itself should also 
>>> >> be
>>> >> an improvement in terms of code size), and sorting the linker input by
>>> >> alignment.
>>> >
[...]
>>> > My GCC manpage claims that
>>> > "-Os disables the following optimization flags: -falign-functions ..."
>>> > and -Os is set in GCC_ALL_CC_FLAGS, and as far as I can see not
>>> > overridden for AARCH64, except for DEBUG builds.
>>> >
>>>
>>> OK, that means we will need to build the RELEASE Shell components with
>>> -O2 rather than -Os if we ever hit the same issue for RELEASE builds.
>>> Since those modules are not the ones where we are likely to care
>>> deeply about code size, this is not a showstopper I think
>>
>> Could we move the -falign-functions=4 to DEBUG_GCCnn_AARCH64_CC_FLAGS
>> instead then, next to the -O0? I'd prefer keeeping dead parameters off
>> the command line where possible.
>>
>> Of course, could make sense to change the DEBUG_GCCnn_AARCH64_CC_FLAGS
>> to include a common DEBUG_GCC_AARCH64_CC_FLAGS variable where these
>> are set instead.
>>
>
> Well, since this applies to GCC49 DEBUG only, let's add it only there
> instead. GCC49 currently means '4.9 or later', and I hope we will not
> have a need to introduce GCC5 etc, and if that does happen, let's
> worry about it then.
>

I double checked this, and it turns out that -Os implies
-falign-functions=4, so while it does disable it usually, it does not
in this particular case.

I will still move it to the DEBUG flags, though, since that is the
only place we need it.
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to