wolfSSL / wolfssl

The wolfSSL library is a small, fast, portable implementation of TLS/SSL for embedded devices to the cloud. wolfSSL supports up to TLS 1.3 and DTLS 1.3!
https://www.wolfssl.com
GNU General Public License v2.0
2.23k stars 799 forks source link

[Bug]: error: symbol already defined with WOLFSSL_SP_ASM enabled on ARM Compiler v6 with high size optimization (-Oz) #7645

Closed DGA45 closed 3 weeks ago

DGA45 commented 3 weeks ago

Contact Details

dgatien@intevaproducts.com

Version

5.7.0

Description

Compiled with Keil uVision on a Cortex-M3, several errors like this one are reported in the file sp_cortexm.c:

sp_cortexm.c(31511): error: symbol 'L_sp_256_sqr_8_store' is already defined
 31511 |     "L_sp_256_sqr_8_store:\n\t"
       |      ^
<inline asm>(50): note: instantiated into assembly here
   50 | L_sp_256_sqr_8_store:
      | ^

Options WOLFSSL_SP_ASM and WOLFSSL_SP_ARM_CORTEX_M_ASM are enabled.

The issue is due to the compiler setting using highest size optimization (-Oz option with armclang), as explained in the GCC compiler manual:

Under certain circumstances, GCC may duplicate (or remove duplicates of) your assembly code when optimizing. This can lead to unexpected duplicate symbol errors during compilation if your asm code defines symbols or labels. Using ‘%=’ (see AssemblerTemplate) may help resolve this problem.

After adding '%=' in all the labels from sp_cortexm.c, the code is compiling properly, ie: "L_sp_256_sqr_8_store%=:\n\t"

#if defined(__GNUC__) || defined(__ICCARM__) || defined(__IAR_SYSTEMS_ICC__)
        "BGT    L_sp_256_sqr_8_store%=\n\t"
#else
        "BGT.N  L_sp_256_sqr_8_store%=\n\t"
#endif

Reproduction steps

Relevant log output

No response

SparkiDev commented 3 weeks ago

Hi @DGA45

I've prepared a fix for this: #7649

Let me know if this works for you!

Sean