On 02/11/2023 10:23 pm, Stefano Stabellini wrote:
> On Thu, 2 Nov 2023, Andrew Cooper wrote:
>> On 02/11/2023 10:21 am, Federico Serafini wrote:
>>> Remove the generic implementation of memcpy(), memmove() and
>>> memset() from the x86 build since a version written in asm is present.
>>> This addesses violations of MISRA C:2012 Rule 8.6 ("An identifier with
>>> external linkage shall have exactly one external definition").
>>>
>>> Signed-off-by: Federico Serafini <[email protected]>
>> As I said on one of the previous calls, this is an error in analysis,
>> not a bug in Xen.
>>
>> The behaviour when linking a library is well defined by the toolchain.
>> Disassemble the final hypervisor and observe that there really is only
>> one implementation, and it's always the arch-optimised version when both
>> exist.
> This is done automatically by linker, right? I am asking because I was
> curious and searching through the build system but couldn't find a
> specific place where the dropping of the lib implementation of things is
> done.
It's a property of linking, yes.
There is a specified order that libraries are searched (L->R on the
cmdline, IIRC) and the first object in a library to provide the symbol
is the object that gets linked in.
There are corner cases where you can pull in unrelated code and end up
with multiple symbols of the same name, and this is explicitly mitigated
by having one (public) function per object file wihtin the libs.
~Andrew