I want to use a wolfssl library(https://github.com/wolfSSL/wolfssl) on ARM Cortex-A9 processor. So, I used arm-none-eabi-gcc cross compiler on Ubuntu and got a static link library "libwolfssl.a".
Compilation and link was succeed, but "PemToDer" function(ssl.c) crashes.
I explored clash point by using logging functions. The cause of clash was " header=BEGIN_CERT; ". BEGIN_CERT is a const char* type and defined in asn.c.
int PemToDer(const unsigned char* buff, long longSz, int type, ......)
{
const char* header = NULL;
const char* footer = NULL;
...
switch (type) {
case CA_TYPE: /* same as below */
case TRUSTED_PEER_TYPE:
case CERT_TYPE:
header=BEGIN_CERT; // clash here!
footer=END_CERT;
break;
case CRL_TYPE: header=BEGIN_X509_CRL; footer=END_X509_CRL; break;
I turned off gcc optimization and looked again the CFLAGS, but it was meaningless.
I replaced BEGIN_CERT with END_CERT, but END_CERT cause a clash, too.
To identify the cause, I wrote an simple function which returns BEGIN_CERT on wolfssl library(libwolfssl.a) and RTOS's task and called two functions from RTOS's task.
const char *test(void){ return BEGIN_CERT; }
The result is ... clashed on wolfssl library and not clashed on RTOS's task.
So, I compared the assembly code. These are some difference. I'm not very familiar with assembly but I think address is correct.
The code below was clashed.
18024cac <test1>:
18024cac: e59f2014 ldr r2, [pc, #20] ; 18024cc8 <test1+0x1c>
18024cb0: e08f2002 add r2, pc, r2
18024cb4: e59f3010 ldr r3, [pc, #16] ; 18024ccc <test1+0x20>
18024cb8: e7923003 ldr r3, [r2, r3]
18024cbc: e5933000 ldr r3, [r3]
18024cc0: e1a00003 mov r0, r3
18024cc4: e12fff1e bx lr
18024cc8: 07ffbfe0 ldrbeq fp, [pc, r0, ror #31]!
18024ccc: 00000000 andeq r0, r0, r0
The code below was not clashed.
18008cd4 <test2>:
18008cd4: e59f3004 ldr r3, [pc, #4] ; 18008ce0 <test2+0xc>
18008cd8: e5930000 ldr r0, [r3]
18008cdc: e12fff1e bx lr
18008ce0: 20020b98 mulcs r2, r8, fp
My guess is the cause of clash is in the test1 code above. What could be the cause of this problem?
Please forgive me my lousy English.
Appreciate your help.