> On May 12, 2016, at 5:30 AM, Michael Zimmermann <[email protected]>
> wrote:
>
>> For AARCH64, that would be sufficient, but for ARM there are plenty of
>> other compiler intrinsics, so you should always include the
>> CompilerIntrinsicsLib.inf anyway (which the upstream DSCs are already
>> doing)
>
> since there already seems to be AArch64 support
> in ArmPkg/Library/CompilerIntrinsicsLib which supports memcpy, the fix for
> this bug probably should be to add this lib to the platform's dsc instead
> of editing the compiler options.
>
The CompilerIntrinsicsLib is needed in general for the platform, but its memcpy
is hiding a more general case bug. I had a long talk with our compiler team,
who also work on the open source LLVM, and there is no way to turn off the
memcpy (other than not coding the structure assignments).
The structure assignment in code can fail with any compiler, but small ones are
usually hidden by the optimizer.
For example what I see with clang is if you disable optimizations you always
see the memcpy(), but if you optimize the optimizer removes the memcpy() as an
optimization.
~/work/Compiler>cat memcpy.c
int
main (int argc, char **argv)
{
int test[16] = { 1, 2, 3, 4, 5 , 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
return test[argc];
}
~/work/Compiler>clang -O0 -S memcpy.c
~/work/Compiler>cat memcpy.S | grep memcpy
callq _memcpy
~/work/Compiler>clang -Os -S memcpy.c
~/work/Compiler>cat memcpy.S | grep memcpy
So I think this is a bug in the code, it is just being hidden by the optimizers
on x86, and the CompilerIntrinsicsLib on ARM. If this code was compiled with
clang NOOPT it would likely also fail to link.
Thanks,
Andrew Fish
> On Thu, May 12, 2016 at 2:21 PM, Ard Biesheuvel <[email protected]>
> wrote:
>
>> On 12 May 2016 at 14:17, Michael Zimmermann <[email protected]>
>> wrote:
>>>> The EDK2 build system already does that for IPF under GCC>
>>>>
>>>> DEFINE GCC_IPF_SYMRENAME_FLAGS = --redefine-sym memcpy=CopyMem
>>>
>>> this probably should be moved to the global GCC flags then, also GCC can
>>> generate other symbols too, i.e. "struct x = {0};" results in memset.
>> (this
>>> one would need a wrapper though because SetMem uses a different argument
>>> order).
>>>
>>
>> For AARCH64, that would be sufficient, but for ARM there are plenty of
>> other compiler intrinsics, so you should always include the
>> CompilerIntrinsicsLib.inf anyway (which the upstream DSCs are already
>> doing)
>>
> _______________________________________________
> edk2-devel mailing list
> [email protected]
> https://lists.01.org/mailman/listinfo/edk2-devel
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel