From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (EUR04-DB3-obe.outbound.protection.outlook.com [40.92.74.99]) by mx.groups.io with SMTP id smtpd.web12.9648.1653499228694838441 for ; Wed, 25 May 2022 10:20:29 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@outlook.com header.s=selector1 header.b=Ee9lHxoH; spf=pass (domain: outlook.com, ip: 40.92.74.99, mailfrom: kilian_kegel@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hIhsM0zxlt+hrDbpl+2Cx+qJnqLY1Oku2bMNLTNM7ca46tTU/YkC4ZZ6zV4symzbSySyR7gEZ4FKiQqMzHV80QAiqkhLi2Ikt9MyWZKXXkuYrFJuHbrqwnnUpBWDQ5grvUidOzaBU74uvkLmZjbeyPDYfMi0whHOZi1wuqH/Qs87++2bz8aQVOisMaji2t9f1srJd83NvE5r8wpzBFJKIc6CmtByadfBUwK4TSLepjvy0834tyS7cISQex4WBOR/VfKcOfH+il2vAFXRJXkfjtJJflqlUYvdkyNTYoGgjUEBFsrqdCSlOhyeTk94tmW+GLlXoaTWEE3wCxQgOT8lXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lYOLfFXFAfM2muMvpovKFE6UVpffqCpi043mDL2ZJp8=; b=mSz21tbrIeygTrI2Xxy+kIK6HEnTkwhFZdW170asDCAHaQtwuhnb0IJvSk4fXB4fkR/Mx8FgUwMCPN1bcCcW9I9ZtmltFSVCGnr62xSWWrqQlN8Vb7CWqbyOrjHAhD3lFZdL/KINdOpREeH0HBhuoNACuiEX5z0C3PLkLg8IXt9OMC3VAEclelyeHjFuhEJtgWxJPErHQshpgr9D10KoHnL6Qyfj1QD54CFq43qFqWfax50lNhEQ1lvy6V4V580m4B+AgXiqCP3CQQ1GewzuyU/aEWkYWO5MAWuglCFAUhPv9XNKxmIlP0/JnnNiVylXHH5eFKpTLMNbKPDVOYu35A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lYOLfFXFAfM2muMvpovKFE6UVpffqCpi043mDL2ZJp8=; b=Ee9lHxoHOtM0ajZI6vzVyvh/noNlXE9jKYAq1CgNfBiigHCOnHmz05A4l+JoUaWf8DtgCSxjbX0a+manHx5FGi23wKdykBpkCa3UsmqMh1OywoyZlWgk8ymIngk6b5i26ETKaVovHqG3F0nhOeDTpEGBUC1IYiQO4w0D/lDlIBX5rWMQqBKq3fr7staTk6/tBn0XJxMCzR6wKqP93HtF5S/X9UBi1DG551Ne6BZ1QJ5rh3RZ+8AaaZRe4NteykbQKofkntCyyPdTY02LHz9kARW18nnQWdA7bgO0jEkhGx+1dDIy5v/jw29JZig2TfS59D5ZD5l+4IWpHl7qz2amvQ== Received: from AS8P189MB2072.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:521::5) by AM9P189MB1785.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:430::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13; Wed, 25 May 2022 17:20:26 +0000 Received: from AS8P189MB2072.EURP189.PROD.OUTLOOK.COM ([fe80::a0ad:dd5f:d691:8a94]) by AS8P189MB2072.EURP189.PROD.OUTLOOK.COM ([fe80::a0ad:dd5f:d691:8a94%9]) with mapi id 15.20.5227.021; Wed, 25 May 2022 17:20:26 +0000 From: "Kilian Kegel" To: "devel@edk2.groups.io" , "xzavierpower@gmail.com" Subject: Re: [edk2-devel] including redfish libs results in multiple definitions of symbols Thread-Topic: [edk2-devel] including redfish libs results in multiple definitions of symbols Thread-Index: AQHYcFO9YlT7V0lP9EGEJPOAL3wllK0vx/us Date: Wed, 25 May 2022 17:20:26 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-tmn: [cZqgfYmRyz1LGuI0k3RhAH1XKBnzeIa5fpPcZ5fhg7Alr7RzjeOxyYT4S2yHX5Zh] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 0c058b4e-d4a8-46e5-7f1b-08da3e72dbfe x-ms-traffictypediagnostic: AM9P189MB1785:EE_ x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: tLd+vvJwwkFOUl+jQ3KODGJWEnSw/pA64QjO2WbACTnJYTRk+UKdX3meZyn5ojQNVacMOhh9jtagIBteaE2y97yCmyK3P8hTy9AjhoRclU1FxBL+t4iealvrgDI7fDmzYqTjfwscEDW2+ssmLGg6oblele+cQfNkg1rWmqj+aUyz8MOT6LVyG24dTggJ0rqVeKj0BiXOotfL0fQd+J8ZKkAvLXYRi1sFadUABUktcqaq9fhPEeZmpKwZcPf2oGZ4zeAnf+DWT2AgZcFXy0IhysuG7GJEX2MqlcoeHKokLxOZVg9C/ATInaz1DHeeQUeIy4NDlhP7tsOVfcLJYBW47cCoxoMIeoNuH/aXWYwUGBK9u/FHlu6IAOKaWAXjQysMSrVTjtvDwCshXV1lMsaebH3xFSk5/Tg0kclEyiW5RDxzIBP1njkZ/cHDdGITXymbDJ5i+hu7acNVPaoA2OpFf5xCwXMyHfX3tsKIZOpi4wZQO4y8iSc+gxf0UuXQk/3wtYq7pjZ/LCJ31yyGcU1Fm7WNIqVb2BJ/GbFUxgEW7PHhHavOES8kOGcZ8VxJ+jRdEjhv3UHlqKe0R1FY2z3px1QaLgHW1WMlCKULG1KNkgleqQajFMROqp0zoai5Ys4tRIyQyyBeP1PQG8TB9Zs+HW1JQWm2IFJeJls0fsQOVgQ= x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?Windows-1252?Q?MiyTR20aCPFEOW0G+P6kPCpbA6edV0GDPRpLYef6+IgtxYCopijuVX4r?= =?Windows-1252?Q?SW8HQ8e2+56IIjiNonuD0niZi1lggF4qUBu1XUXtYuVsDHo30d8AtDT/?= =?Windows-1252?Q?613aN3+NCXS1u3Z3ytJz6HPOEuBWRx37SgBgGJFg48vDp8BcNCjaXoGt?= =?Windows-1252?Q?l/fasFTw8sdgpwbbagK1wjRlYoJ9nYjYdd3c1phxe9fJDu0fGLdFuOcq?= =?Windows-1252?Q?ONC4M5HoDJmWXM5hcBu3qeX+m9qJLrNcn3MX4AWw8nBOktL9U4Z1PCW5?= =?Windows-1252?Q?32cUEkFHzKntkbkgF6SgE5MPjsSCWuCbTul+E8roX/GNWGvLLzjEK9qr?= =?Windows-1252?Q?+6U5o41OohC7XmudDCvH5hKUonx+Vi/S+9fCsFLS0VXCqmojVTJP2OQv?= =?Windows-1252?Q?/lT4Fk1VsX0RgEPLGxbsx2X7T+6JkDOX5jZMZRqj5eQgsAZNUFD0wSox?= =?Windows-1252?Q?P5TZIddsTwKJo0ZDDTPsTf4n2Hn2WBnFbr9Ddx9AU2wJ05ZxcrvOc9uO?= =?Windows-1252?Q?VDTIqqfprogq0Cf76b6yDPEquqP+YzjANPQC4kQs1DVcAs4ExuExgwVT?= =?Windows-1252?Q?dwAtbhYY9N2eSxTHRoxSfN2uoF8LSR2qY0nySUMXi6/ORwKNys/heiSK?= =?Windows-1252?Q?JP+LlLcAp1Uip18JUNp+2xP2Q8eGVKKDSChPcfonKlxqQ6Scfr2C9LUb?= =?Windows-1252?Q?2dMeW0TGE6YABVqhYeu1z07ugJ/0H8jEJwZm1SzBebdVQWn6+cWjcDCG?= =?Windows-1252?Q?WWAdrLqpRSW4c2vsubxQnRjuPfeq37leU2lANvk8NWnP2noX70HJAiLn?= =?Windows-1252?Q?ksdbvzernzVlhGdzZfEqzXv9FS+10wzmkqqj574DyVrtpKswSfzoLMu/?= =?Windows-1252?Q?Y/ih3Er6CKWnqH2jdQlpfeUW39Y4O1jkZ+oTEj/RH379T8KtK/JaM0v1?= =?Windows-1252?Q?lm7TpSVD04GUYn//DBufeuQXmMd5xYM+qyDS8lT1mY5bDRK4I86fp4eN?= =?Windows-1252?Q?QYK+ReRxTYjaWoOYnL6NtiLLf9aAw/f3+Q2Kt8MWSCXpovhfY5x9lAYw?= =?Windows-1252?Q?1TSvuOy6gZag7aSzjyL5U9+9X765D2oeTdMxCfNUD9dPCoSj1dYEqMnz?= =?Windows-1252?Q?C1zr+1BOzKVyg+WMacGeYDYVFOntaX8FB6jWijrZnap4RYscehVlaiZR?= =?Windows-1252?Q?rAtcleP/csgI48Bay8sHhU4tIxD1E92H+VjCLo97BEBAiqJFP/Ype+VH?= =?Windows-1252?Q?eSo9acjqozLmk45YTkoq6FJp10bRFXDpCrRGNbdWx3NBkfQLBOnBDKJh?= =?Windows-1252?Q?Haf45kZAIgKcbA9DMXnf8q43pkwL3Qn/R1e3dWqIIyFXYR3tUoKGNxIN?= =?Windows-1252?Q?MsRBtQg8SHw39XDLC/kADz9il5mi78Mv0N73lujDbroicabQbULGhxxU?= =?Windows-1252?Q?UwtZM1YX0P5BIfsb/FoMibrlrZQQePJeAffHeV9FXDd9+jyEqmgpSs9j?= =?Windows-1252?Q?mzW0uwUA45MzZB2mewJqtHR0onGD3PrSCrLEu1W5vw6stISDcKKi/KSi?= =?Windows-1252?Q?L6Cbi0iCC9r/yLLkfKJI16RG/jxIiU7IycQMelQS5hn4fq16/2tz/uim?= =?Windows-1252?Q?aTqoVHg4BPm6srptKkIgp4aP?= MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AS8P189MB2072.EURP189.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: 0c058b4e-d4a8-46e5-7f1b-08da3e72dbfe X-MS-Exchange-CrossTenant-originalarrivaltime: 25 May 2022 17:20:26.3960 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9P189MB1785 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_AS8P189MB20728FA6368981ABD3817950EBD69AS8P189MB2072EURP_" --_000_AS8P189MB20728FA6368981ABD3817950EBD69AS8P189MB2072EURP_ Content-Type: text/plain; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable Hi xp, your build failure is 1. the result of a =93link-all=94 mechanism or 2. the result of a library construction flaw that is commonly used i= n EDK2. or both Let me explain the theory: 1. an .OBJ file is created by the compiler for each .C source code file an .OBJ is considered as atomic, it can not be split into smaller pieces (e= xcept with newer compiler switches) 1. a =93library=93 .LIB is a collection of one or more of such .OBJ file= s 2. if an .OBJ is passed to linker, it is _always_ linked into the target= .EFI (the linker creates an link-error, like yours, if that particular symbol-na= me is already present in the target.EFI) One definition rule: https://docs.microsoft.com/en-us/cpp/error-messages/to= ol-errors/linker-tools-error-lnk2005?view=3Dmsvc-170 1. if an .LIB is passed to the linker instead, the linker searches the .= LIB for a particular symbol (e.g. function, data). The specific .OBJ module that holds that part= icular symbol, is linked to the target.EFI. (the linker creates an link-error, like yours, if that particular symbol-na= me is already present in the target.EFI) One definition rule: https://docs.microsoft.com/en-us/cpp/error-messages/to= ol-errors/linker-tools-error-lnk2005?view=3Dmsvc-170 1. to prevent such error each .OBJ of a library can hold only one single= symbol, one function or one data. Only in that case the linker is able to pickup each single symbol from the = library and bind it into the target.EFI without any conflict. This is also explained here: https://github.com/tianocore/edk2-staging/tree/CdePkg/blogs/2021-12-19#redf= ishcrtlib-conflicts-with-cdepkg-by-design Best regards, Kilian ________________________________ From: devel@edk2.groups.io on behalf of M.T. Sent: Wednesday, May 25, 2022 6:23:02 PM To: devel@edk2.groups.io Subject: [edk2-devel] including redfish libs results in multiple definition= s of symbols Hello I'm working on a small UEFI shell app. I was hoping to make use of the JsonLib found in the Redfish Package. When I include the Redfish JsonLib and it's dependencies: JsonLib|RedfishPkg/Library/JsonLib/JsonLib.inf Ucs2Utf8Lib|RedfishPkg/Library/BaseUcs2Utf8Lib/BaseUcs2Utf8Lib.inf RedfishCrtLib|RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.inf BaseSortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf BaseSortLib has symbol clashes with SortLib resulting in the following: /usr/bin/ld: UefiSortLib.obj (symbol from plugin): in function `PerformQuic= kSort': (.text+0x0): multiple definition of `PerformQuickSort'; BaseSortLib.obj (sy= mbol from plugin):(.text+0x0): first defined here /usr/bin/ld: UefiSortLib.obj (symbol from plugin): in function `PerformQuic= kSort': (.text+0x0): multiple definition of `DevicePathCompare'; BaseSortLib.obj (s= ymbol from plugin):(.text+0x0): first defined here /usr/bin/ld: UefiSortLib.obj (symbol from plugin): in function `PerformQuic= kSort': (.text+0x0): multiple definition of `StringNoCaseCompare'; BaseSortLib.obj = (symbol from plugin):(.text+0x0): first defined here /usr/bin/ld: UefiSortLib.obj (symbol from plugin): in function `PerformQuic= kSort': (.text+0x0): multiple definition of `StringCompare'; BaseSortLib.obj (symbo= l from plugin):(.text+0x0): first defined here I need SortLib for UEFIShell dependencies, and I need BaseSortLib for JsonL= ib. Is there some way around this? Or is Redfish meant to be standalone? Thank you in advance xp --_000_AS8P189MB20728FA6368981ABD3817950EBD69AS8P189MB2072EURP_ Content-Type: text/html; charset="Windows-1252" Content-Transfer-Encoding: quoted-printable

Hi xp,

 

your build failure is

  1. the result of a =93link-all=94 mechanism

or

       2. the result o= f a library construction flaw that is commonly used in EDK2.

 

or both

 

Let me explain the theory:

 

  1. an .OBJ file is created by the compiler for each .C source code file<= /li>

an .OBJ is considered as atomic, it can not b= e split into smaller pieces (except with newer compiler switches)

  1. a =93library=93 .LIB is a collection of one or more of such .OBJ file= s
  2. if an .OBJ is passed to linker, it is _always_ linked in= to the target.EFI

(the linker creates an link-error, like yo= urs, if that particular symbol-name is already present in the target.EFI)

One definition rule: https://docs.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tool= s-error-lnk2005?view=3Dmsvc-170

  1. if an .LIB is passed to the linker instead, the linker searches the .= LIB for a particular

symbol (e.g. function, data). The specific .O= BJ module that holds that particular symbol, is

linked to the target.EFI.

(the linker creates an link-error, like yo= urs, if that particular symbol-name is already present in the target.EFI)

One definition rule: https://docs.microsoft.com/en-us/cpp/error-messages/tool-errors/linker-tool= s-error-lnk2005?view=3Dmsvc-170

  1. to prevent such error each .OBJ of a library can hold only one single= symbol, one function or one data.

Only in that case the linker is able to picku= p each single symbol from the library and bind it into the target.EFI

without any conflict.

 

This is also explained here:

 

Best regards,

Kilian

 


From: devel@edk2.groups.io = <devel@edk2.groups.io> on behalf of M.T. <xzavierpower@gmail.com&g= t;
Sent: Wednesday, May 25, 2022 6:23:02 PM
To: devel@edk2.groups.io <devel@edk2.groups.io>
Subject: [edk2-devel] including redfish libs results in multiple def= initions of symbols
 
Hello

I'm working on a small UEFI shell app.
I was hoping to make use of the JsonLib found in the Redfish Package.<= /div>

When I include the Redfish JsonLib and it's dependencies:
JsonLib|RedfishPkg/Library/JsonLib/JsonLib.inf
Ucs2Utf8Lib|RedfishPkg/Library/BaseUcs2Utf8Lib/BaseUcs2Utf8Lib.inf
RedfishCrtLib|RedfishPkg/PrivateLibrary/RedfishCrtLib/RedfishCrtLib.inf
BaseSortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf

BaseSortLib has symbol clashes with SortLib resulting in the following= :

/usr/bin/ld: UefiSortLib.obj (symbol from plugin): in function `Perfor= mQuickSort':
(.text+0x0): multiple definition of `PerformQuickSort'; BaseSortLib.obj (sy= mbol from plugin):(.text+0x0): first defined here
/usr/bin/ld: UefiSortLib.obj (symbol from plugin): in function `PerformQuic= kSort':
(.text+0x0): multiple definition of `DevicePathCompare'; BaseSortLib.obj (s= ymbol from plugin):(.text+0x0): first defined here
/usr/bin/ld: UefiSortLib.obj (symbol from plugin): in function `PerformQuic= kSort':
(.text+0x0): multiple definition of `StringNoCaseCompare'; BaseSortLib.obj = (symbol from plugin):(.text+0x0): first defined here
/usr/bin/ld: UefiSortLib.obj (symbol from plugin): in function `PerformQuic= kSort':
(.text+0x0): multiple definition of `StringCompare'; BaseSortLib.obj (symbo= l from plugin):(.text+0x0): first defined here

I need SortLib for UEFIShell dependencies, and I need BaseSortLib for = JsonLib.
Is there some way around this?  Or is Redfish meant to be standal= one?

Thank you in advance
xp
--_000_AS8P189MB20728FA6368981ABD3817950EBD69AS8P189MB2072EURP_--