Jiewen:
  When CLANG9 is used, CLANG compiler always removes _fltused symbol, and cause 
the linker issue. 
 __attribute__((used)) variable attribute informs the compiler that a static 
variable is to be retained in the object file, even if it is unreferenced.

 So, I add this attribute for _fltused symbol and let compiler keep this symbol 
for linker. I find GCC and CLANG both supports this attribute. Then, I add it 
for GCC and CLANG both. 

Thanks
Liming
>-----Original Message-----
>From: Yao, Jiewen
>Sent: Friday, September 27, 2019 4:34 PM
>To: devel@edk2.groups.io; Gao, Liming <liming....@intel.com>
>Subject: RE: [edk2-devel] [Patch 09/12] CryptoPkg IntrinsicLib: Make _fltused
>always be used
>
>Hi
>
>+int  GLOBAL_USED _fltused = 1;
>
>May I know what is the use of GLOBAL_USED? Only for compiler stub symbol?
>
>If so, why we add __GNUC__ here? Any other usage?
>
>+#if defined(__GNUC__) || defined(__clang__)
>+  #define GLOBAL_USED __attribute__((used))
>+#else
>+  #define GLOBAL_USED
>+#endif
>
>> -----Original Message-----
>> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Liming
>Gao
>> Sent: Friday, September 27, 2019 3:47 PM
>> To: devel@edk2.groups.io
>> Subject: [edk2-devel] [Patch 09/12] CryptoPkg IntrinsicLib: Make _fltused
>always
>> be used
>>
>> With this change, global variable _fltused will not be removed by LTO
>>
>> Signed-off-by: Liming Gao <liming....@intel.com>
>> ---
>>  CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c | 10 ++++++++--
>>  1 file changed, 8 insertions(+), 2 deletions(-)
>>
>> diff --git a/CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c
>> b/CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c
>> index 6e4d4a68cc..94fe341bec 100644
>> --- a/CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c
>> +++ b/CryptoPkg/Library/IntrinsicLib/MemoryIntrinsics.c
>> @@ -2,7 +2,7 @@
>>    Intrinsic Memory Routines Wrapper Implementation for OpenSSL-based
>>    Cryptographic Library.
>>
>> -Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
>> +Copyright (c) 2010 - 2019, Intel Corporation. All rights reserved.<BR>
>>  SPDX-License-Identifier: BSD-2-Clause-Patent
>>
>>  **/
>> @@ -13,9 +13,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
>>
>>  typedef UINTN  size_t;
>>
>> +#if defined(__GNUC__) || defined(__clang__)
>> +  #define GLOBAL_USED __attribute__((used))
>> +#else
>> +  #define GLOBAL_USED
>> +#endif
>> +
>>  /* OpenSSL will use floating point support, and C compiler produces the
>_fltused
>>     symbol by default. Simply define this symbol here to satisfy the linker. 
>> */
>> -int _fltused = 1;
>> +int  GLOBAL_USED _fltused = 1;
>>
>>  /* Sets buffers to a specified character */
>>  void * memset (void *dest, int ch, size_t count)
>> --
>> 2.13.0.windows.1
>>
>>
>> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#48263): https://edk2.groups.io/g/devel/message/48263
Mute This Topic: https://groups.io/mt/34309062/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to